I am using 'lsqcurvefit' to fit a nonlinear model ( Actualy a fourier series in which I know the frequencies. I want the amplitude of each sin/cosine term). So problem is like this,
suppose I have 'N' grid point and for each grid point I have time series data for which I know three dominant frequencies. Now the model which I want to fit on the time series for each grid is
H=A+B*t + C1*cos(2.pi.f2*t)+ C2*sin(2.pi.f1*t)+ C3*cos(2.pi.f2*t)+
C4*sin(2.pi.f2*t)+ C5*cos(2.pi.f3*t)+ C6*sin(2.pi.f3*t)
As I mentioned, I know the value of f1, f2, f3 for each grid and want to estimate A,B,C1,C2,... for each grid. Here 't' is independent variable.
I want to do this in loop for i=1:N and change the value of 'f' for each loop as I have these values for each grid.
Can you please help me out from this problem.
Here is what I was trying but its not working. Firstly I define a function with some function name say 'FUN' hence
then using lsqcurvefitting
Please help me out