3D mesh - Limit Z axis height, but just for the function, not the entire 3D domain
7 ビュー (過去 30 日間)
古いコメントを表示
I'm trying to draw a parabola in 3D. However, I want to limit its extents.
I am able to limit the X and Y extents pretty easily, through the function.
ie: which limits the x to 0 to 2, and the y from -5 to 1.
X=linspace(0,2,20);
Y=linspace(-5,1,20);
However, the Z, I want to limit this aswell. So I used:
zlim([0 4])
It worked, but now my entire 3D domain is cropped! and I need to show other elements.
Any idea on how this can be achieved? I suspect my function is a bit primitive.
Sorry, I'm matlab illiterate but just starting out. I don't know enough to ask this question properly. THANK YOU for any Help!
total code:
%Curve, parabola in 3d, with limits
X=linspace(0,2,20);
Y=linspace(-5,1,20);
[X,Y]=meshgrid(X,Y);
Z=((Y.^2));
surf(X,Y,Z);
%Limit the Z axis
zlim([0 4])
%basic graphics
x1=[-3 3 3 -3];
y1=[0 0 0 0];
z1=[0 0 6 6];
patch(x1,y1,z1, [0.71 0.72 .73]);
rotate3d on
0 件のコメント
採用された回答
Matt J
2022 年 5 月 11 日
編集済み: Matt J
2022 年 5 月 11 日
One possibility.
X=linspace(0,2,20);
Y=linspace(-5,1,20);
[X,Y]=meshgrid(X,Y);
Z=((Y.^2));
Z(Z>=4)=nan;
surf(X,Y,Z);
%basic graphics
x1=[-3 3 3 -3];
y1=[0 0 0 0];
z1=[0 0 6 6];
patch(x1,y1,z1, [0.71 0.72 .73]);
view(-75,25);
3 件のコメント
Matt J
2022 年 5 月 11 日
You're very welcome, but please Aceept-click the answer to certify that it worked.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!