plot for fmincon with multiple value of parameter

8 visualizaciones (últimos 30 días)
Ni
Ni el 8 de Jul. de 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

Respuesta aceptada

Shashank Prasanna
Shashank Prasanna el 8 de Jul. de 2013
I posted the answer in your previous questions here:
  4 comentarios
Shashank Prasanna
Shashank Prasanna el 9 de Jul. de 2013
You will find all that information for customization right here:
Ni
Ni el 9 de Jul. de 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');

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by