is there any formula linking COEFF with ahat (wmpalg vs. lsqcurvefit issue) ?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Antworten (1)
Matt J
am 19 Dez. 2014
Bearbeitet: Matt J
am 19 Dez. 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 Kommentare
Siehe auch
Kategorien
Mehr zu Polynomials finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!