Hello,
My goal is to fit the best these filtered data (attached) with the equation :
x(1)*exp(-x(2)*t).*sin(2*pi*x(3)*t+x(4)).
Here is my code (below) but this algorithm doesn't give a good fitting.
I don't know if it is a problem of parameters (for example, how to choose x0, ub and lb. I read some information on Matlab website but it doesn't help me)…
Thanks in advance for your help !
fun = @(x,t) x(1)*exp(-x(2)*t).*sin(2*pi*x(3)*t+x(4));t=[0:1/1000:(1/1000*(length(data_TRT)-1))];x0 = [2,1,1,1] options = optimoptions('lsqcurvefit','Algorithm','levenberg-marquardt');lb = [0,0,0,-1]ub = [2,100,100,1][x,resnorm] = lsqcurvefit(fun,x0,t,data_TRT,lb,ub,options)figureplot(t,data_TRT,'k-',t,fun(x,t),'r-')legend('Experimental Data','Modeled Data')title('Data and Fitted Curve')xlabel('Temps (secondes)')Damping_Nigg =x(2)Frequence_Nigg =x(3)
Best Answer