Can someone tell me what I'm doing wrong. I have looked over this for quite a while already with no success. I think I am messing up when it comes to element by element operation, but I have tried everything I know with no luck.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Frank_m
am 3 Apr. 2015
Kommentiert: Star Strider
am 3 Apr. 2015
%this script will plot a 3-D plot of P(v) as a function of v and T
M=0.032;
R=8.31;
x=[0:1000];
y=[70:320];
[X,Y]=meshgrid(x,y);
Z=4*pi*(M/(Y.*2*pi*R)).^(3/2)*(X.^2).*exp((-X.^2*M)./(Y.*2*R))
surf(X,Y,Z)
xlabel('v (m/s)');ylabel('T (K)');zlabel('P(v)')
0 Kommentare
Akzeptierte Antwort
Star Strider
am 3 Apr. 2015
When in doubt, vectorise everything!
This works:
M=0.032;
R=8.31;
x=[0:1000];
y=[70:320];
[X,Y]=meshgrid(x,y);
Z=4*pi*(M./(Y.*2*pi*R)).^(3/2).*(X.^2).*exp((-X.^2*M)./(Y.*2*R));
mesh(X,Y,Z)
xlabel('v (m/s)');ylabel('T (K)');zlabel('P(v)')
I replaced your surf call with mesh because the surf plot was so dense it looked completely black (in R2015a).
4 Kommentare
John D'Errico
am 3 Apr. 2015
Bearbeitet: John D'Errico
am 3 Apr. 2015
The black lines arise because matlab uses black edges in the grid. You can turn them off with a set command, something like
H = surf(X,Y,Z);
set(H,'edgecolor','none')
or you can use the shading command as I usually do, because it is easy to remember when I am feeling lazy.
surf(X,Y,Z)
shading interp
Either will kill the black lines in the surface.
Star Strider
am 3 Apr. 2015
Thank you, John. I don’t myself encounter that problem often enough to have searched for a different solution other than switching to mesh. I’ll consider the 'edgecolor' and ‘shading’ options next time.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!