least square curve fitting
5 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Stephen23
on 8 Oct 2014
Edited: Stephen23
on 8 Oct 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".
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!