Plotting Inequalities in Matlab
87 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
KSSV
on 28 Jun 2022
Edited: KSSV
on 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' ;
More Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
