Is there a way to annote the fitting parameters with 95% coefficient into the plot. I am trying to do curve fit some data in a loop and want to displya the fitting results directly in the plot, may in some textbox. For example I am doing some curvefitting in the following code
x=-0:0.1:10;
x=transpose(x);
y=2*exp(-x/5)+0.1*rand(numel(x),1);
ft=fittype('a*exp(-x/b)','independent','x','dependent','y');
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.StartPoint =[1,1,];
[fitresults,gof]=fit(x,y,ft,opts);
plot(fitresults,x,y,'.')
disp(fitresults)
Which generates plot like this
and the fitting results are displayed in the command window in the following way
General model:
fitresults(x) = a*exp(-x/b)
Coefficients (with 95
a = 2.031 (2.015, 2.047)
b = 5.329 (5.258, 5.4)
I want to display the fitting results inside the plot something like this
Is it possible to do using script.