How to determine start and end points of fitting curve?
Show older comments
Hi all, I have
x=[0.25 0.50 0.75 1]
y=[0.0001 0.1 0.6889 10]
and I use power(2) to get the fitting curve. Is there a way to determine some points in the fitting curve? Because, when I get my fitting curve equation and use the above data, I get for x=0.25,y = 0.048 which is quite far from 0.00001. Any idea anyone how can I fix this?
Answers (1)
A power model doesn't fit these data worth a hooey at the lower end...try
plot(f,x,y,'*')
set(gca,'yscale','log')
ylim([y(1)/2 y(end)*2])
to see the problem; the curvature is positive for the fitted curve but negative in that region for the actual data. It appears either a 'power1' or linear in both log(x) log(y) would be a better fit of these data than 'power2'.
Addendum
b=polyfit(log(x),log(y),1); % fit log-log
yh=exp(polyval(b,log([x(1) x(end)]))); % Evaluate at end points
hold on
plot([x(1) x(end)],yh,'c') % add to the previous plot
You'll see this is quite a lot closer...but looking at residual errors one finds that the power1 model may be best overall...will leave that as "exercise for the student" :)
1 Comment
dpb
on 1 Dec 2015
Oh, which illustrate why one should never curvefit w/o first plotting the data to see what gives...
Categories
Find more on Get Started with Curve Fitting Toolbox 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!