frequency obtained by cftool is 10 times less than what I should get

1 次查看(过去 30 天)
Hi everyone, I am using fourier series for one of my application. I was getting wrong result, so I decided to check the fit(t,variable,'fourier1') for small application. I used the following code to generate a cos wave
%%Angular Frequency
omega=0.65;
%%Time specifications:
Fs = 10; % samples per second
dt = 1/Fs; % seconds per sample
StopTime =200*omega/pi; % seconds
t = (0:dt:StopTime-dt)'; % seconds
%%Sine wave:
x = cos(omega*t);
% Plot the signal versus time:
figure;
plot(t,x);
I used this cos wave in cftool and fit function. both gave me results as in figure.
as you can see, in result I got w=omega=0.065 whereas The original signal was having angular frequency as 0.65;
I have tried this for other frequency too and result is always 10 times less. What am i doing wrong ?
  2 个评论
David Goodmanson
David Goodmanson 2017-5-15
Hi Kunal, I don't have access to cftool but this gives the impression that some part of the calculation is not getting the message that your time array has spacing of 1e-1. If it were assumed instead that the spacing is 1, then the calculated omega is down by a factor of 10. If you change Fs to 20, does the answer change by that same factor?
Kunal Tiwari
Kunal Tiwari 2017-5-15
@David, You nailed it. Changing Fs to 20 made the w reduce by half. I changed Fs to 1 and I got expected result. I was making the mistake of letting matlab assume the sampling frequency. Thanks.

请先登录,再进行评论。

回答(1 个)

John D'Errico
John D'Errico 2017-5-14
Decent starting values are critical to finding a good estimate. If you provide no starting values at all, then you get an arbitrary result, often something that will not make you happy.
  1 个评论
Kunal Tiwari
Kunal Tiwari 2017-5-14
But does that mean matlab does not use traditional fourier series formulas ?
Actually my application involves equating the coefficients (a0,a1,b1) for getting estimations. So do you think it's better to try and implement these formulas over trying to use fit function ?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by