Plotting Inequalities in Matlab
89 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
John Buethe
am 28 Jun. 2022
Kommentiert: John Buethe
am 28 Jun. 2022
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;
0 Kommentare
Akzeptierte Antwort
KSSV
am 28 Jun. 2022
Bearbeitet: KSSV
am 28 Jun. 2022
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' ;
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

