least square fitting and phase shift
古いコメントを表示

Hi, I have few doubts in Least square curve fitting and phase shift in Matlab !!
Here is my problem !
I have 100 values data for time and current (which is not pure sinusoidal, slightly increasing in time). I have to make a least square fitted curve out of these data.
1. what is the significance of initial values ('x0')giving in the 'lsqcurvefit'?
2. How can I give the initial values x0=[x(1) x(2) x(3)], where x(1) =dc offset, x(2) =amplitude of sine, x(3)=phase shift ? Because it is the current signal which we are going to find out, so how can we predict this one step before !!
> Equation I selected is ' x(1)+x(2)*sin(2*pi*100*t+x(3)) '
3. If I am not wrong , we are optimizing the values given to the 'x0', pls correct me if I am wrong.
4. Does the 'output' values give an optimized value for x(1),x(2),x(3) ?
5. Does the x(3) from 'output' give the phase shift of current to voltage ?
6. Does the x(1)+x(2) from 'output' of last period give the maximum value of the current ?
My ultimate aim is to find the phase shift ! (Im not using FFT)
Here is my code .
'data' has 3 columns, Time, Current, Voltage
T= data{1} ; % time 100 values for 10 periods
I= data{2} ; % current 100 values
V= data{3} ; % voltage 100 values (sine voltage)
L2_T=T(end-19:end); % time points in last 2 periods
L2_I=I(end-19:end); % current points in last 2 periods (selected bcy which are more sinusoidal than previous periods)
L2_V=V(end-19:end); % voltage points in last 2 periods (sine voltage)
options = optimset('Display','off');
x0 = [5 1 pi/3 ] ; % initial values for lease sqr fit
F = @(x,xdata) x(1)+x(2)*sin(2*pi*100*xdata+x(3)); % least sq SINE
output = lsqcurvefit(F,x0,L2_T,L2_I,[],[],options); % least sq result
time = L2_T(1)+1e-7 :1e-7:L2_T(end); % to make the least sq current more smooth and for close fitting
Lst_sq_I=F(output,time );
You can suggest any other method for more precise result.!
採用された回答
その他の回答 (1 件)
Sami Gernaz
2016 年 12 月 10 日
0 投票
hi Mohan, I'm trying to run your script in Matlab but it is not working any help plz? still new to matlab. thank you
カテゴリ
ヘルプ センター および File Exchange で Waveform Generation についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!