How do I plot the intersection of two inequalities?

I have these two inequalities and I wanna have something like the graph:
I used this code to get this graph, and rotate the axis to show only the xy-plane, but I wanted to represent this area using only the two inequalities.
[x1,x2] = meshgrid(-10:0.02:10,-10:0.02:10);
z = x2 - 8./x1;
cond1 = x1./5 - x2 >= 0;
cond2 = 16 - (x1-5).^2 - x2.^2 >= 0;
cond = cond1.*cond2; z(cond == 0) = NaN;
mesh(x1, x2, z);

2 件のコメント

Chen
Chen 2023 年 10 月 9 日
Excuse me, what is sense of the cond = cond1.*cond2; z(cond == 0) = NaN ?
Thanks
Torsten
Torsten 2023 年 10 月 9 日
NaN values are not plotted.

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

回答 (2 件)

Mathieu NOE
Mathieu NOE 2023 年 10 月 10 日

1 投票

try this :
[x1,x2] = meshgrid(-10:0.02:10,-10:0.02:10);
z = x2 - 8./x1;
cond1 = x1./5 - x2 >= 0;
cond2 = 16 - (x1-5).^2 - x2.^2 >= 0;
cond = cond1.*cond2; z(cond == 0) = NaN;
surf(x1, x2,0*z, z);
shading interp
view(2)

1 件のコメント

Mathieu NOE
Mathieu NOE 2023 年 12 月 11 日
hello again
do you mind accepting my answer (if it has fullfiled your expectations ) ? tx

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

Ayush Modi
Ayush Modi 2023 年 10 月 10 日

0 投票

Hi Gustavo,
As per my understanding, you would like to see the area covered by both the inequalities.
Here is an example showing how you can implement the same:
inq1 = ((1/5)*X) - Y >= 0;
inq2 = 16 - (X-5).^2 - Y.^2 >=0;
% Combine the inequalities
% area = inequality1 & inequality2;
area = inq1 & inq2;
% Create a figure and plot the area
figure;
fill(X(area), Y(area),'b');
Hope this helps!

カテゴリ

ヘルプ センター および File ExchangeLine Plots についてさらに検索

製品

リリース

R2018a

タグ

質問済み:

2020 年 9 月 17 日

コメント済み:

2023 年 12 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by