在不使用 FFT 的情况下找到信号的频率

finding the frequency of signal without using FFT

我有带噪声的正弦信号,其中每次振荡的噪声点数在我的代码中应该相同每次振荡五个点),我想每次更改振荡数:2,3,4 ... .15(在我的代码中更改变量 "random")

在每次振荡时,我将提取振幅作为频率的函数<不幸的是,对于少数振荡,FFT 不起作用,信号中的点太少,所以我必须拟合信号(正弦噪声) 到正弦波,以便将新信号的频率与正弦波的频率进行比较

查看我的代码,如何进行拟合,以便提取信号的频率?

  %my code
  random=40;
  f=5; % the frequency of the sine wave also the number of points per 
     oscillation

  %the number of oscillation is random/f

  t = (1:random)';
  X = ones(random,2);


  y_1= sin((2*pi)/f*t);
  X(:,2) = y_1;
  y=y_1+randn(random,1);
  y = y(:);
  beta = X\y;
  yhat = beta(1)+beta(2)*sin((2*pi)/f*t);
 figure
 plot(t,y,'.b','markersize',12);
 hold on
 plot(t,yhat,'r','linewidth',2);

这是一个常见问题。请尝试以下链接或 Whosebug 上的其他链接。在你的例子中,你有很多异常值,所以你使用像 RANSAC 这样的方法把它们扔掉。

https://www.mathworks.com/matlabcentral/answers/121579-curve-fitting-to-a-sinusoidal-function

https://www.mathworks.com/matlabcentral/answers/195371-sine-curve-fitting-for-the-given-data