Plotting a 2D matrix
300 ビュー (過去 30 日間)
古いコメントを表示
Alok Pathak
2014 年 6 月 27 日
コメント済み: Gnaneswar Nadh satapathi
2014 年 6 月 27 日
I need to plot a matrix M which is 300*42 in size. On the X axis I need to plot 1:42. On the Y Axis I need to plot the value corresponding to the 42 values. On the Z axis I need to plot the 1:300 value.
I tried using the plot3 function in a loop like this and I wouldnt get it right :
for i = 1:300
plot( 1:42, M(i, 1:42), 1:i);
hold on;
drawnow ;
end
I get the error Vectors are not of similar lengths. Please Help. Many thanks
Regards
3 件のコメント
採用された回答
Andrei Bobrov
2014 年 6 月 27 日
編集済み: Andrei Bobrov
2014 年 6 月 27 日
s = size(M);
[z,x] = ndgrid(1:s(1),1:s(2));
data = permute(num2cell(cat(3,x,M,z), 2),[3,2,1]);
plot3(data{:});
or
s = size(M);
[x,z] = ndgrid(1:s(2),1:s(1));
plot3(x,M.',z);
0 件のコメント
その他の回答 (1 件)
David Sanchez
2014 年 6 月 27 日
Maybe you are thinking no something like this:
M=rand(300,42); % your data here
[xx, yy] = meshgrid(1:42,1:300);
plot3(xx,yy,M,'*')
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!