How can I stop part of my plot?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I am a MATLAB noob and I need your help.
I have a college task to make this:
,
,and instead of that so far I got this:

This is the code I am using:
% initial values
a = 0.2;
b = 0.2;
c = 0.4;
K = 40;
L = 70;
xos = 0:5:70;
yos = 0:5:80;
[x,y] = meshgrid(xos,yos);
u = a*x.*(1-(x/K));
v = b*y.*(1-(y./(L-c*x)));
hold on
y = yos;
x = K*ones(size(y));
hold on
plot(x,y)
x = xos;
y = L-c*x;
hold on
plot (x,y)
startx1 = 15;
starty1 = 30;
redLine = streamline(xos,yos,u,v,startx1, starty1);
set(redLine,'Color','red')
startx2 = 60;
starty2 = 20;
blueLine = streamline(xos,yos,u,v,startx2,starty2);
set(blueLine,'Color','blue')
startx3 = 60;
starty3 = 60;
greenLine = streamline(xos,yos,u,v,startx3,starty3);
set(greenLine,'Color','green')
startx4 = 15;
starty4 = 80;
cyanLine = streamline(xos,yos,u,v,startx4,starty4);
set(cyanLine,'Color','cyan')
Thank you for your time and help.
4 comentarios
Adam Danz
el 14 de Jul. de 2019
Editada: Adam Danz
el 14 de Jul. de 2019
Is the assignment to create a plot using streamline() and then to remove some sections from each line? That sounds odd. Using your code and changing as little as possible, one way would be to replace some of the (X,Y) coordinates of a line with NaN values.
Here's an example to execute after all of the lines in your example.
cyanLine.YData(30:end) = NaN; %replace y coordates from 30 to 223 with NaNs
Respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!