is there any formula linking COEFF with ahat (wmpalg vs. lsqcurvefit issue) ?
1 次查看(过去 30 天)
显示 更早的评论
Your lsqcurvefit function defined as depicted below:
myfunction = @(a,T) a(1)+a(2)*Tm+a(3)*Tm.^2);
[ahat,resnorm,residual,exitflag,output,lambda,jacobian]=lsqcurvefit(myfunction,a0,Tm,Rm);
provides a(1)=ahat(1), a(2)=ahat(2) and a(3)=ahat(3) which explicitly represent three coefficients of the second order polynomial myfunction. On the other hand [YFIT,R,COEFF,IOPT,QUAL,X] = wmpalg(...) delivers coefficients which can be used to generate the function fit (YFIT) using the following formula:
YFIT = P * COEFF;
Vector P, however, is synthetized from normalized “linspased”- formatted argument, consequently COEFF array is different from that provided by ahat. Since I am not anymore quite fluent in matrix algebra (out of college long time ago), my question would be: is there any formula linking COEFF with ahat? I am trying to assemble auto-codable Simulink model and succeeded in calculating COEFF, however, for subsequent data processing in the real time I need to generate ahat.
I would be very grateful for your help
1 个评论
回答(1 个)
Matt J
2014-12-19
编辑:Matt J
2014-12-19
COEFF as returned by wmpalg would have to be a scalar multiple of your ahat and possibly has the coefficients in a different order. I think it is irrelevant, however. Both wmpalg and lsqcurvefit are unnecessarily complicated for simple polynomial fitting. You should just use polyfit,
coeff=polyfit(Tm,Rm,2)
To obtain the fit to the y-data, you would then use polyval,
YFIT = polyval(coeff,Tm);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Polynomials 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!