Plotting Inequalities in Matlab
85 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
KSSV
le 28 Juin 2022
Modifié(e) : KSSV
le 28 Juin 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' ;
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

