put me out of my misery
이전 댓글 표시
i have 3 matrices..
x = 1 * 264;
y = 1* 264;
z = 1 * 264;
contour(x,y,z) % error z must be 2* 2 or more
hence i did
[X,Y] = meshgrid(x,y); Z =griddata(x,y,z,X,Y);
contour(X,Y,Z) is giving some weird plot. Not desirable.
Now how to do it...
댓글 수: 2
Iain
2014년 1월 31일
What are you trying to plot?
contour(x,y,z) is expecting x to be a vector with n elements, y a vector with m elements, and z to be n by m (or is it m by n)
채택된 답변
추가 답변 (3개)
Mischa Kim
2014년 1월 31일
Rizwana, first option works just fine. Make sure that Z is an mxn matrix, where m and n are the length of the two vectors x and y. meshgrid , e.g., generates an appropriate grid.
x = rand(10,1);
y = rand(10,1);
[X,Y] = meshgrid(x,y);
Z = sin(X)+cos(X+Y);
figure
contour(X,Y,Z)
or see the documentation.
댓글 수: 3
Rizwana
2014년 1월 31일
Mischa Kim
2014년 1월 31일
The contour plot is more of a 3D type plot, where the dependent variable (Z) depends on two variables (X, Y). So it is not quite clear to me what you would like to achieve.
Rizwana
2014년 1월 31일
Looks like you actually want: plotyy or subplots:
plotyy(x,y,x,z) % plot angle against radius on the left hand y axis, and pressure against radius on the right hand y axis.
subplot(211)
plot(x,y)
subplot(212)
plot(x,z)
or
subplot(121)
plot(x,y)
subplot(122)
plot(x,z)
obviously, switch the x,y,z's around to plot against what you want to. - contour plots are only valid for 2-D signals, and you've only got 3 1D signals.
댓글 수: 3
Iain
2014년 1월 31일
Is circumferential pressure supposed to be a function of angle and radius?
If radius has "n" elements, and you have "m" angles, then you should get "n x m" pressures, and not have all three as being vectors.
For example, with a trivial function I know is wrong:
x= 0:0.1:1;
y= 0:36:360;
z = x' * y;
contour(x,y,z)
would work.
Rizwana
2014년 1월 31일
Walter Roberson
2014년 1월 31일
0 개 추천
댓글 수: 7
Rizwana
2014년 1월 31일
Walter Roberson
2014년 1월 31일
I did say it was new. Use TriScatteredInterp then.
Rizwana
2014년 1월 31일
Walter Roberson
2014년 1월 31일
Could you remind me of which MATLAB version you are using?
Rizwana
2014년 1월 31일
Walter Roberson
2014년 1월 31일
It appears that TriScatteredInterp appeared in R2009a. griddata() does exist in your release though.
Rizwana
2014년 2월 3일
카테고리
도움말 센터 및 File Exchange에서 Contour Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!