is there any formula linking COEFF with ahat (wmpalg vs. lsqcurvefit issue) ?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Réponses (1)
Matt J
le 19 Déc 2014
Modifié(e) : Matt J
le 19 Déc 2014
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 commentaires
Voir également
Catégories
En savoir plus sur Polynomials dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!