Polyfit generates Nan coefficients
6 views (last 30 days)
Show older comments
Hi, I'm trying to determine a third degree polynomial fit from my excel data. I have done this before and there's been no problem (although I've only used polyfit up to a degree of 2) but for some reason a, b, c and d (the coefficients of the third degree polynomial return as NaN?! I've done this on excel and I know they're quite low (a=10^-24) but this should still work right?! Also d should be 291.05 so in that case d should at least show, which it doesn't... Someone please help!
clc clear
filename='216 distal testing.xlsx'
stretch=xlsread(filename,1,'Q:Q')
truestress=xlsread(filename,1,'S:S')
p1=polyfit(truestress,stretch,3); stretchinvfit=p1(1)*truestress.^3+p1(2)*truestress.^2+p1(3)*truestress+p1(4);
a=p1(1)
b=p1(2)
c=p1(3)
d=p1(4)
0 Comments
Answers (2)
Matt J
on 16 Jan 2015
If it worked before on different data, then the data you have now is bad...
John D'Errico
on 16 Jan 2015
There is a good chance that your model is having a problem. With a coefficient as small as 1e-24, you are verging into numerical nightmares. The linear algebra will probably be having a difficult time estimating coefficients with a huge dynamic range. 25 powers of 10 or so is just too much for MATLAB to handle.
FAR better is to scale your data, but to help you more, we would really need to see some data.
410 points is nothing.
0 Comments
See Also
Categories
Find more on Polynomials 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!