下面是一個簡單的選擇:
A = [0.0085 0.0244 0.0335 0.0312 0.0392 0.0392
0.0246 0.0078 0.0234 0.0281 0.0395 0.0395
0.0299 0.0295 0.0108 0.0224 0.0598 0.0598
0.0253 0.0317 0.0236 0..0583 0.0583
0.0363 0.0337 0.0500 0.0497 0.0038 0.0583];
back = [1 0 0];
headers = [0.5 0.5 0.5];
minima = [0 1 0];
map = [back ; headers; minima];
colormap(map)
[~,ind] = min(A);
B = zeros(size(A));
for k = 1:size(A,2)
B(ind(k),k) = 1;
end
B = [ones(1,size(B,2))*0.5;B];
B = [ones(size(B,1),1)*0.5 B];
imagesc(B)
axis off
[y,x]=ndgrid((1:size(A,1)),(1:size(A,2)));
row_titles = num2str((1:size(A,1)).'); % could be any vector...
text(ones(size(A,1),1),2:size(A,1)+1,row_titles,'FontSize',16,'HorizontalAlignment','center',...
'VerticalAlignment','middle','Color','w')
coloumn_titles = num2str((1:size(A,2)).'); % could be any vector...
text(2:size(A,2)+1,ones(size(A,2),1),coloumn_titles,'FontSize',16,'HorizontalAlignment','center',...
'VerticalAlignment','middle','Color','w')
text(x(:)+1,y(:)+1,num2str(A(:)),'FontSize',16,'HorizontalAlignment','center',...
'VerticalAlignment','middle')
這給:
,你可以改變headers
,back
和minima
顏色,以滿足您的首選風格。
它看起來像你試圖迫使MATLAB EXCEL ... – EBH
只是想節省從matlab轉移到Excel的時間。由於我只需要可視化部分,並且可以在matlab中直接完成,所以爲此花費時間。我想你的答案也會幫助其他人。幹得好,再次感謝;-)。 – ThT