Error trying to define an output function
Show older comments
Hello to everybody!! I can't understand how to correctly define an output function. I tried to define a function which plot the histogram of residuals on each iteration on this way:
function stop=his(x,optimValues,state)
stop=false;
switch state
case 'init'
figure
title('residual_plot')
case 'iter'
plot(histogram(optimValues.residual,15))
otherwise
end
But I recived this error:
Error using plot
Not enough input arguments.
Error in his (line 8)
plot(histogram(optimValues.residual,15))
I used lsqnonlin with 'OutputFcn' option.
I hope somebody could help me. Thanks
Accepted Answer
More Answers (1)
Image Analyst
on 9 Dec 2016
I don't know what the purpose of stop is. You don't even use it, and you shouldn't even use it because it's a built-in function that stops the time.
histogram does the plotting by itself, so don't pass it to plot(). Just call it:
histogram(optimValues.residual, 15);
grid on;
You should fancy it up by setting xlabel and ylabel, you can set the bar color, and the bar edge color and bar width, etc.
Categories
Find more on Histograms 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!