Plot multiple lines + fmincon
Afficher commentaires plus anciens
Hi, I need to plot multiple lines in one graph, with different values of the the parameters.
The first line with value a=-0.02 and b=0.05;
The second line with value a=-0.05 and b=0.05;
Based on these values, I derived optimal solution and plot the optimal solutions.
see below the detailed codes of a single line in the graph with one set of a and b.
x0=[0,0,0,0];
m=2;a=-0.02;b=0.05;d=0.9;c=0.05;
f = @(x,r)(-x(1)*x(2)*(m-x(2)-c)-(1-x(1))*x(2)*(m-x(2)+(a+b)/2-c)-d*x(3)*x(4)*(m+x(1)*x(2)+(1-x(1))*x(2)*r-x(4)-c)-d*(1-x(3))*x(4)*(m+x(1)*x(2)+(1-x(1))*x(2)*r-x(4)+(a+b)/2-c))
r=0:0.05:1
for ii = 1:length(r)
x(:,ii),fval]=fmincon(@(x)f(x,r(ii)),x0,[],[],[],[],[0;0;0;0],[1;2;1;2])
end
plot(r,x(1,:))
title('Figure Title');
xlabel('x');
ylabel('y');
Réponses (0)
Catégories
En savoir plus sur Line Plots 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!