Plot {(x,y,z)| x²+y²<1, 0<z<x+2}

1 回表示 (過去 30 日間)
Eileen Lassler
Eileen Lassler 2021 年 2 月 10 日
回答済み: Rik 2021 年 2 月 10 日
I'm not sure abot the code, because of the 2 constraints. I hope someone can help me.

回答 (2 件)

Constantino Carlos Reyes-Aldasoro
Constantino Carlos Reyes-Aldasoro 2021 年 2 月 10 日
It depends on what you want. One way to code this would be to define your space, i.e. the range of each of each variable, say x goes from -5 to 5 in steps of 0.1:
x=-5:-.1:5;
and the same for y and z. Then x^2 + y^2 < 1 becomes a condition, those points below 1 could be selected and those above discarded, then you do the same with the second condition and your answer could be a cloud of points where the two conditions intersect.

Rik
Rik 2021 年 2 月 10 日
Same general idea as @Constantino Carlos Reyes-Aldasoro, but more in steps.
Use linspace or colons to create one or three vectors to define your coordinate grid.
Then you can use ndgrid or meshgrid to expand that/those vector(s) to a full grid.
Now use element-wise operations (.* and ./ and .^) to compute . The logical operators < and > will work element-wise by default.
Now you have logical arrays where the combination of x,y,z is either valid or invalid. You can use logical indexing to either remove them, or mark a value array with NaN.
Now you have x y and z vectors, which you can input to a function like plot3 to show the pointcloid.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by