Error trying to define an output function
古いコメントを表示
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
採用された回答
その他の回答 (1 件)
Image Analyst
2016 年 12 月 9 日
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.
カテゴリ
ヘルプ センター および File Exchange で Histograms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!