how to plot 3D graph using mesh() for a rectangular matrix of data?

조회 수: 2 (최근 30일)
bsd
bsd 2011년 7월 20일
Dear sir/madam,
I am using mesh() to plot 3D graphs. To plot a 3D graph the length of x-axis and y-axis must be equal, using mesh(). But I need to plot a 3D graph where the length of x-axis and y-axis are not equal. When I tried to plot the graph for unequal lengths, it showed "dimensions do not agree". How can I plot a 3D graph for unequal lengths, using mesh()? Looking forward for your reply.
Thanking you, BSD

채택된 답변

Christoph
Christoph 2011년 7월 20일
Maybe I missunderstood your problem but as far as I know the axis do not have to be of the same length.
x=1:1000;y=1:3500;%axis
for iter1=1:length(x)
for iter2=1:length(y)
z(iter1,iter2)=y(iter2)/x(iter1);%data
end
end
mesh(y,x,z)%plot it
y and x are not of the same length. The lengths of y,x need to fit the size of z though.
  댓글 수: 3
bsd
bsd 2011년 7월 20일
Thanks for the reply. But what do you mean by "the lengths of y, x need to fit the size of z though", in your reply.
Thanking you,
BSD
Christoph
Christoph 2011년 7월 20일
@andrei
thanks for your comment, I'm not that well versed with bsxfun and the like.
@bsd
I mean just what andrei wrote in his answer
"Z - array (of type)double with size [length(x),length(y)]"

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Andrei Bobrov
Andrei Bobrov 2011년 7월 20일
[X,Y] = meshgrid(x,y);
Z = fun(X,Y);% or Z - array double with size [length(x),length(y)]
mesh(X,Y,Z)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by