Two planes cutting each other

22 ビュー (過去 30 日間)
Duong Nguyen
Duong Nguyen 2020 年 4 月 24 日
コメント済み: Tommy 2020 年 4 月 24 日
I'm supposed to draw graph of two plane : the picture must look like this :
This is my code and It does not work out :
x = linspace (0,1,20);
z = linspace (0,1,20);
[x z]= meshgrid(x,z);
y = sqrt(x) + 0*z;
hold on ;
xlabel('x','FontSize',20);
ylabel('y','FontSize',20);
zlabel('z','FontSize',20);
surf(x,y,z,'FaceColor','b','FaceAlpha',0.5,'EdgeColor','none');
x = linspace (0,1,20);
y = linspace (0,1,20);
[x y]= meshgrid(x,y);
z = 1 - y + 0*x;
zlim = ([ 0 1] );
hold on ;
surf(x,y,z,'FaceColor','b','FaceAlpha',0.3,'EdgeColor','none');
I hope you guys could help me to solve this problem
Thank you !

採用された回答

Tommy
Tommy 2020 年 4 月 24 日
One option is to set x, y, and z values to NaN if they do not fall in the appropriate region:
[x1, z1] = meshgrid(linspace(0,1,500));
y1 = sqrt(x1);
[x2, y2] = meshgrid(linspace(0,1,500));
z2 = 1 - y2;
i1 = y1+z1>1;
i2 = y2<sqrt(x2);
x1(i1) = NaN;
y1(i1) = NaN;
z1(i1) = NaN;
surf(x1,y1,z1,'FaceColor','b','FaceAlpha',0.5,'EdgeColor','none');
hold on;
x2(i2) = NaN;
y2(i2) = NaN;
z2(i2) = NaN;
surf(x2,y2,z2,'FaceColor','b','FaceAlpha',0.3,'EdgeColor','none');
view([120 30])
zlim([0 1.5]);
ylim([0 1.5]);
xlim([0 1.5]);
xlabel('x','FontSize',20);
ylabel('y','FontSize',20);
zlabel('z','FontSize',20);
  2 件のコメント
Duong Nguyen
Duong Nguyen 2020 年 4 月 24 日
Thank you Tommy :)
Tommy
Tommy 2020 年 4 月 24 日
Happy to help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by