Polyfit generates Nan coefficients
이전 댓글 표시
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)
답변 (2개)
Matt J
2015년 1월 16일
0 개 추천
If it worked before on different data, then the data you have now is bad...
댓글 수: 2
Why not attach the offending truestress, stretch data in a .mat file so that we can try it ourselves?
Incidentally, the better way to calculate the fitted points is with polyval
stretchinvfit=polyval(p1,truestress);
John D'Errico
2015년 1월 16일
0 개 추천
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.
카테고리
도움말 센터 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!