Writing custom plot functions in optimisation
Show older comments
Hi. I'm using multiStart routine and I'm struggling to write a plot function that shows the start pint, and optimum point in each set of the local algorithm runs. To do this I think I need to pass the solutions array ( output from run fucntion) to my plot function as an input like below- but matlab has difficulty callling it- even when I set it as a Global variable the array appears as empty in the workspace and I receive the error: too many input arguments!
Questions: 1- If this is wrong what is a better way of calling the start point X0 and optimum solution X apart from calling solutions?
Question: 2- Are the middle points saved anywhere during the process? I need to plot the path from start to end point.
Thanks for the help
function stop = myplotfcn(solutions,state)
stop = false;
switch state
case 'done'
figure; hold on
for i=1:soluno
x0=solutions(1,i).X0;
x0=cell2mat(x0);
x=solutions(1,i).X;
h1=plot(x0(1),x0(2),'b*');
plot([x0(1) x(1)],[x0(2) x(2)],'k');
h2=plot(x(1),x(2),'r*');
legend([h1,h2],'start point','optimum');
end
hold off
end
Accepted Answer
More Answers (0)
Categories
Find more on Surrogate Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!