フィルターのクリア

Simple Question: How to graph certain surfaces depending on the Z value?

1 回表示 (過去 30 日間)
A
A 2015 年 4 月 29 日
コメント済み: A 2015 年 4 月 29 日
Hi guys,
I'm trying to graph only Test1 for Z2 > 5, and wanting to graph only Test2 for Z2 < 5.
x = [0:5];
y = [0:5];
Test1 = @(x,y)(x+y);
Test2 = @(x,y)(2.*x+y);
[X1,Y1] = meshgrid(x,y);
Z1 = Test1(X1,Y1);
Z2 = Test2(X1,Y1);
% s1 = surf(X1,Y1,Z1);
% s2 = surf(X1,Y1,Z2);

採用された回答

pfb
pfb 2015 年 4 月 29 日
You could set the points that do not meet your constraint to NaN;
i = Z1<5;
Z1(i)=NaN;
i = Z2>5;
Z2(i)=NaN;
The result is a bit jagged with your small grid, though.
  1 件のコメント
A
A 2015 年 4 月 29 日
Perfect. Thanks. I used your suggestion to modify the code and here is the working result. No worries about the jaggedness because this is just a test:
x = [0:5];
y = [0:5];
Test1 = @(x,y)(x+y);
Test2 = @(x,y)(2.*x+y);
[X1,Y1] = meshgrid(x,y);
Z1 = Test1(X1,Y1);
Z2 = Test2(X1,Y1);
i = Z1<5;
Z1(i)=NaN;
s1 = surf(X1,Y1,Z1);
hold on
i = Z2>5;
Z2(i)=NaN;
s2 = surf(X1,Y1,Z2);

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by