Plot function variables for each iteration in fmincon
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Suvrat Ramasubramanian
el 23 de Sept. de 2017
Comentada: Xingwang Yong
el 8 de Abr. de 2021
Hi,
I am trying to plot the variables values calculated for each iteration in fmincon. @optimplotx give histogram plot but i want to plot separately each variable for my function. I am able to plot for each function evaluation, but i want the variable values to be plotted for each iteration just like @optimplotfcn.
0 comentarios
Respuesta aceptada
Matt J
el 23 de Sept. de 2017
Editada: Matt J
el 24 de Sept. de 2017
You can specify your own custom PlotFcn. You don't have to use one of the pre-written choices like, @optimplotx.
function stop = myplotfun(x, optimValues, state)
persistent data
if ~nargin % example reset mechanism
data=[];
end
if strcmp(state,'iter')
data=[data,x(:)];
plot(data.');
end
stop=0;
end
11 comentarios
Xingwang Yong
el 8 de Abr. de 2021
It seems the reset mechanism above is made wrong on purpose. For completeness, this is one that works
function stop = myplotfun(x, optimValues, state)
persistent data
if strcmp(state,'init') % example reset mechanism
data=[];
end
if strcmp(state,'iter')
data=[data,x(:)];
plot(data.');
end
stop=0;
end
Más respuestas (0)
Ver también
Categorías
Más información sobre Problem-Based Optimization Setup en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!