MATLAB: How to print fval and optimised values at each iteration

fminsearch outputfunction

Hi I have a very simple task: printing fval and x values of each iteration. I already printed x values of each iteration, as mentioned in Outputfunction. However I have no luck printing fval of each iteration.

Best Answer

Use the optimvalues structure to get fval, as described here