Plot - show fitting error

7 views (last 30 days)
Auryn_
Auryn_ on 5 Mar 2019
Answered: darova on 5 Mar 2019
Hi,
Starting with a set of data points, I use a fitfun function to fit it to a nonlinear scaling function A^x.
Now, I would like to quantify the error of the fits themselves, to understand how the points deviate from the scaling function.
May I ask for any help to do this?
Thanks!

Answers (1)

darova
darova on 5 Mar 2019
A = 1.9;
x = linspace(0,4,50);
y = A.^x + rand(1,50);
res = fit(x',y','A.^x');
y1 = res.A.^x;
plot(x,y,'.',x,y1)
legend('data','fit')
figure
title('Error')
plot(x,y1-y)

Community Treasure Hunt

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

Start Hunting!