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!