- You can write a Custom plot function using this link. The reference file in the link can show the syntax in which you can get the X(1), X(2), fval and iteration number.
- This information you can append in three variables and plot fval as color intensity using surf.
- Try to append the values in current iteration in an array so that you may plot current and previous values also to the surface plot.
- For every PlotFcns option the .m file is there in MATLAB and you can take help of how to access data in between of iterations.
- Other way is to plot the 2D curve that contains variables value on one subplot and fval on other subplot with respect to the iterations. This can be done as follow:
- Return the values of variables and fval that are taken between iterations by writing a custom OutputFcn for which syntax is mentioned here.