For loop plotting all values in one graph, how do I create separate plots for my for loop values
Afficher commentaires plus anciens
% Mesh Grid in (Diamtoms(D),Zooplankton(P))-plane
[D, P] = meshgrid(-0.8:1:10, -0.8:1:10);
% Parameters
hold on
for K=1:10
s=1;
e=1;
r=1;
H=1;
d=0.75;
% System as a 2-D function
f = @(t,X) [X(1)*(r*(1-X(1)*(1/K))-(s*X(1)/1+s*H*X(1))*X(2));
X(2)*(e*(s*X(1))/(1+s*H*X(1))-d)];
%Direction Filed
% Ddot is dD/dt and Pdot is dP/dt derivatives
Ddot = D-(1./K).*D.*D-(s*D)./((1+s.*H.*D)).*P;
Pdot = P.*((s.*D)./(1+s.*H.*D))-P.*d;
% Vector Field
figure(1)
quiver(D,P,Ddot,Pdot,'LineWidth',1.5)
timespan=[0 100];
% Phase Trajectories
X0=0.5*K*rand;Y0=K*rand;
[ts, Xs] = ode45(f,timespan, [X0, Y0]);
% plot of several trajectories
plot(Xs(:,1), Xs(:,2), 'Linewidth', 2)
% Nullclines.
x = linspace(0, 10, 50);
y = linspace(0, 10, 50);
[X, Y] = meshgrid(x, y);
nullcline_x = x .* (1 - x / K - Y ./ (1 + x));
nullcline_y = (4 .* X) ./ (1 + X);
contour(X, Y, nullcline_x, [0, 0], 'r', 'LineWidth', 1);
contour(X, Y, nullcline_y, [0, 0], 'b', 'LineWidth', 1);
xlabel('Prey, D', 'FontSize',14)
ylabel('Predator, P', 'FontSize',14)
set(gca, 'FontSize', 16)
xlim([-0.8 10])
ylim([-0.8 10])
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!









