plot for fmincon with multiple value of parameter

4 vues (au cours des 30 derniers jours)
Ni
Ni le 8 Juil 2013
Does any one know how to plot optimal results w.r.t. the value of m, c below my optimisation problem.
Say, I need to plot m at x axis and x(1) at y axis.
f = @(x,m)(-m*x(1)-2*x(2)-x(1)*x(2))
for m=2:0.2:3
[x,fval]=fmincon(@(x)f(x,m),x0,[1,1],18,[],[],[0;0],[Inf;Inf])
end
Thanks

Réponse acceptée

Shashank Prasanna
Shashank Prasanna le 8 Juil 2013
I posted the answer in your previous questions here:
  4 commentaires
Shashank Prasanna
Shashank Prasanna le 9 Juil 2013
You will find all that information for customization right here:
Ni
Ni le 9 Juil 2013
Hi Shashank, could you help on my problem as below, very urgent. I need to plot multiple lines in one graph. The first line is the optimal solution of x(1) with the value a=-0.02 and b=0.05; The second line is the optimal solution of x(1) with value a=-0.05 and b=0.05;
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');

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by