简体   繁体   中英

Is there a GNU Octave equivalent for the Matlab function “fit”?

My teacher in the signal analysis course has given me some Matlab code that I have to execute in order to complete a home assignment. I have always been using GNU Octave without troubles, but this time there is this command that is giving me headaches.

[c8,g8]=fit(time, sin_4_harmonic,’fourier8’)

I cannot find the function "fit" in GNU Octave, which is referenced for Matlab at the following url http://www.mathworks.se/help/curvefit/fit.html

Does anyone knows which package should I load, or if there is any equivalent?

Thanks =)

As far as I know, that function is not present in any of the Octave packages. However, the best place to look for something similar would be the optim package , probably the function nonlin_curvefit . Looking at the documentation, the model fourier8 is of the type Y = a0+a1*cos(x*p)+b1*sin(x*p)... +a8*cos(8*x*p)+b8*sin(8*x*p) .

A work-around may be using "polyfit" function. To get the values, use "polyval".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM