least square curve fitting

4 visualizzazioni (ultimi 30 giorni)
Vipin Mohan
Vipin Mohan il 8 Ott 2014
Commentato: Vipin Mohan il 8 Ott 2014
Hi
Can anyone help me to do Curve fitting with Non-linear Least Square curve fitting.
I have few points w.r.t time.. and I have to make a SINE wave with these points.
Lets say following are the values (Even though its not similar to a sinusoidal values)
Time Current
04.500 11.452
04.525 11.528
04.550 11.586
04.575 11.623
04.600 11.640
04.625 11.638
04.650 11.620
04.675 11.592
04.700 11.559
I have to make a sinusoidal curve with the help of Non Linear Least square (x = lsqnonlin(fun,x0))... the sinusoidal function can be in the form , CurrentI= A+Sin(w*Time) (with a fixed frequency lets say 200Hz)..
I know the concept of Least sqr method, but the problem is , i am not getting how to make the above function 'fun'.
Thank you.

Risposte (1)

Stephen23
Stephen23 il 8 Ott 2014
Modificato: Stephen23 il 8 Ott 2014
fun is the function handle of the function you wish to fit to the data. It is your job to define a function of the curve you wish to fit, ensuring that it fulfills the requirements of lsqnonlin , which are explained in the documentation.
In particular, the function needs to accept an input vector, and provide an output vector which is the curve given those input values. The lsq function adjusts the input vector until the output vector best matches your given data.
You can also find explanations and examples here:
You might also like to consider using lsqcurvefit , as this "provides a convenient interface for data-fitting problems".
  1 Commento
Vipin Mohan
Vipin Mohan il 8 Ott 2014
Thnkx for the reply..
As I told, i had read thru the explanations and all...but i dont know how can i put the function handle. can i put put simply as 'A+sin(w*t)' .. its a small doubt only.A similar program will also be helpful. That is what I am expecting.3 line program code will be great .!

Accedi per commentare.

Categorie

Scopri di più su Linear and Nonlinear Regression in Help Center e File Exchange

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by