graphing norm of residuals

5 views (last 30 days)
MOH
MOH on 28 Oct 2021
Commented: Walter Roberson on 28 Oct 2021
I used the fminseach to fit non linear equation , how I can graph the residuals . when I seached it I saw it in the graph tool box . how I can graph it if I'm not using the tool box?
  2 Comments
MOH
MOH on 28 Oct 2021
Graphing the residuals as fminsearch progresses

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 28 Oct 2021
You can create an options structure that specifies PlotFcn https://www.mathworks.com/help/matlab/math/plot-functions.html
You can create a custom plot function; https://www.mathworks.com/help/optim/ug/output-function.html
The particular field you would want to plot is named fval
  5 Comments
Walter Roberson
Walter Roberson on 28 Oct 2021
Perhaps you have structured your search along the lines of
[bestpara, bestresidue] = fminsearch(@(parameters) objective(parameters, xdata, ydata), x0);
function residue = objective(parameters, xdata, ydata)
predictions = some function of parameters and xdata
residue = norm(predictions - ydata);
end
If so then to plot the residues, add options to the fminsearch call with 'PlotFcn' of @optimplotfval .

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!