Plot 2D constraints
Mostrar comentarios más antiguos
I have an equation (a-b)x+(c-b)y <= d and i would like to plot 20 instances of this equation.
The limits of the plot are set from -5 to 5. I have already a set of values for the a,b,c,d
Any ideas?
My code so far is:
x = [-5:0.1:5];
L = 20;
hold off
for i=1:L
y = (d-x*(a-b))/(c-b)
plot(x,y)
hold on
end
1 comentario
Respuestas (1)
Star Strider
el 28 de Jun. de 2019
You do not need the loop.
Try this:
x = linspace(-5, 5, 20);
L = 20;
y = (d-x*(a-b))/(c-b);
plot(x,y)
4 comentarios
Jack Haratsi
el 28 de Jun. de 2019
Star Strider
el 28 de Jun. de 2019
My pleasure.
Yes, you did.
Knowing what a, b, c, and d are, and how they relate to the lines you want to plot, would help immensely. Are they the respective ends of the lines? Are they slopes and intercepts? Something else?
Jack Haratsi
el 28 de Jun. de 2019
Star Strider
el 28 de Jun. de 2019
Editada: Star Strider
el 28 de Jun. de 2019
What are the ends of the lines?
How should the lines be defined in terms of a, b, c, and d?
EDIT —
Should they be plotted as:
plot([a(:) b(:)]', [c(:) d(:)]')
Note that this will produce the series of straight lines that you likely want. The question is how to assign the vectors to the matrices here.
Categorías
Más información sobre Numerical Integration and Differentiation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

