7

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 =)

wizclown
  • 313
  • 1
  • 4
  • 16
  • This question appears to be off-topic because it is about math computation functions of a piece of software. – vcsjones Nov 11 '13 at 17:47
  • 7
    @AmirrezaKeshavarz this is not homework. He's asking what's the Octave equivalent to the Matlab function fit because he's trying to do his howework, which was designed for Matlab, in a different language. – carandraug Nov 11 '13 at 19:25
  • @carandraug Thank you so much, this actually solved my problem :) Of course I would never ask people to solve my "homework", moreover it's not proper homework since I'm working my way towards a Master's degree. It is just that I strongly believe in open source software and the ideals behind it, hence my question. – wizclown Nov 22 '13 at 17:39
  • 2
    @vcsjones I don't get why the question is off-topic. Could you please tell me how or where to formulate such a question in the correct way? stackoverflow.com is about programming, and asking information about a function of a scripting language seemed pertinent to me. I see you have a high rank and a lot of experience, hence I believe that I have just to learn from all that. Constructive criticism is always appreciated :) – wizclown Nov 22 '13 at 17:50
  • @user2980080 Well, I am a human being and I can be just as wrong as anyone else. Since no one else agreed with me that it is off topic, perhaps I am wrong :-). Anyway, my original thinking was this was more about a tool (octave), not a programming language. However you're very right that there is a programming language behind it, so I redacted my close vote. – vcsjones Nov 22 '13 at 17:56

2 Answers2

8

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).

carandraug
  • 12,938
  • 1
  • 26
  • 38
0

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