Writing custom plot functions in optimisation
이전 댓글 표시
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
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Surrogate Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!