How can I make the z axis smaller in order for the absolute maximum and absolute minimum to show up on my graph? How can I plot the absolute max/min points in contrasting size and color?
1 次查看(过去 30 天)
显示 更早的评论
So, I have my code, but I am confused on how I can change the z axis to show all 5 of my points. the absolute maximum is 40 at (2,2) and the absolute minimum is -0.125 at (-1/2,0) and (1/2,0).
% Code Plane and Boundaries
x=linspace(-5,6,50);
y=x;
[X,Y]=meshgrid(x,y);
Z=2.*X^4-X.^2+3.*Y^2;
surfl(X,Y,Z)
grid on
hold on
x1=linspace(0,16,30);
y1=linspace(0,0,30);
z1=2.*x1.^4-x1.^2;
plot3(x1,y1,z1,'r*','Markersize',15)
hold on
x2=y1;
y2=x1;
z2=28+3.*y2.^2;
plot3(x2,y2,z2,'r*','Markersize',15)
hold on
x3=x1;
y3=x3;
z3=2.*x3.^4-x3.^2+3.*y3.^2;
plot3(x3,y3,z3,'r*','Markersize',15)
hold on
crx=[-1/2, 1/2,0, 2, 2];
cry=[0, 0, 0, 0, 2];
crz=2.*crx.^4-crx.^2+3.*cry.^2;
plot3(crx,cry,crz,'bd','Markersize', 15,'Markerfacecolor','b')
hold off
0 个评论
回答(1 个)
Walter Roberson
2019-4-23
All 5 markers are plotted. The difficulty you are having is that on that scale, the 3rd marker is so close to the first marker that it is difficult to notice the difference between them, especially as the pane runs right through the third marker
You can use, for example,
zlim([-5 45])
You might want to also use xlim() and ylim() calls.
2 个评论
Walter Roberson
2019-4-23
You might want to use scatter3() to draw the markers instead of plot3(). When you use scatter3() then you can specify a different marker size for every marker.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!