Plotting Inequalities in Matlab

85 ビュー (過去 30 日間)
John Buethe
John Buethe 2022 年 6 月 28 日
コメント済み: John Buethe 2022 年 6 月 28 日
Hey all,
I have to plot some inequalities for a controls assignment for school and I was wondering if you all could help me.
The inequalities are:
x > 0
y > 5/x
y > (x^(2)-25)/5*x
Right now my code looks like this:
figure (3); clf
[x,y] = meshgrid(-10:0.02:10, -10:0.02:10);
ineq = (x > 0) & (y > 5./x) & (y > (x.^(2)-25)./(5*x));
x(~ineq) = NaN;
y(~ineq) = NaN;
plot(x(:),y(:)); box on; grid on;

採用された回答

KSSV
KSSV 2022 年 6 月 28 日
編集済み: KSSV 2022 年 6 月 28 日
x = -10:0.1:10 ;
y = -10:0.1:10 ;
[X,Y] = meshgrid(x,y);
ineq = (X > 0) & (Y > 5./X) & (Y > (X.^(2)-25)./(5*X));
h = pcolor(X,Y,double(ineq)) ;
h.EdgeColor = 'none' ;
If you want to display on the region which satisfies.
x = -10:0.1:10 ;
y = -10:0.1:10 ;
[X,Y] = meshgrid(x,y);
ineq = (X > 0) & (Y > 5./X) & (Y > (X.^(2)-25)./(5*X));
ineq = double(ineq) ;
ineq(ineq==0) = NaN ;
h = pcolor(X,Y,double(ineq)) ;
h.EdgeColor = 'none' ;
  1 件のコメント
John Buethe
John Buethe 2022 年 6 月 28 日
Thank you for your help!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by