fitting a curve to data

Can anyone tell me what mistake I am making here? Can you please suggest any changes which make this code work? Thank you.

 Accepted Answer

Objective functions for lsqcurvefit and nlinfit have to have the parameter argument as the first argument and the dependent variable as the second argument.
This should work:
fun = @(x,xdata) x(1).*sin((x(2).*xdata)+x(3)); %function handle for approx curve

More Answers (0)

Categories

Asked:

on 6 Oct 2014

Edited:

on 7 Oct 2014

Community Treasure Hunt

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

Start Hunting!