简体   繁体   中英

Plotting a 3D surface or volume, given x, y and z intervals

How can I plot a volume described by the following intervals?

3<x<5
0<z<x
0<y<x^2

I've tried to generate two sets of vectors. One describing the start point and one describing an end point between which the surface should be.

%start vectors
x1=3:0.1:5;
y1=zeros(21, 1);
z1=zeros(21, 1);

%end vectors
x2=x1;
y2=x1.^2;
z2=x1;

hold on

%plot the points in the same figure
scatter3(x2,y2,z2);
scatter3(x1,y1,z1);

hold off

However my attempt only displays each point and I'm unsure if they're even correct.

Well your question isn't very clear, but I suppose you want something like this?

[xx,yy] = meshgrid(3:0.1:5,3:0.1:5);
surf(xx,yy,xx.^2);
xlabel('x');
ylabel('y');
zlabel('z');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM