2013-11-27 168 views
0

我試圖實現一個譜相關函數來繪製與衝浪功能。 我想我理解SCF的想法,正如我讀過的論文中所描述的那樣,但我在Matlab中實現我的功能時遇到了困難。我一直在以下這些指示:在Matlab中移動信號的FFT

Pseudo-code

我主要遇到問題妥善轉移我的數據塊。有沒有簡單的方法來實現第3步?

這是我在我的代碼的嘗試:

function [output] = spectral(x, N) 
    % This function does cyclostationary spectral analysis 
    % on a data set and returns some features 

    t = length(x); 
    samplesPerFrame = floor(t/N); 

    count = 1; 

    for alpha = -1:0.01:1 



     % Split up the samples into frames 
     % Have to leave some samples out if unevenly split 
     for i = 1:N+1 
      frange = ((i - 1) * samplesPerFrame + 1):(i * samplesPerFrame); 
      if i == N+1 
       break; 
      end 
      xFrame(i, :) = x(frange); 
      ts = [1:length(xFrame(i,:))]; 
      shiftLeft = fft(xFrame(i, :) .* exp(-1 * 2 * pi * 1i * (alpha/2) .* ts)); 
      shiftRight = fft(xFrame(i, :).* exp(2 * pi * 1i * (alpha/2) .* ts)); 

      S(i,:) = (1/samplesPerFrame) .* shiftLeft .* conj(shiftRight); 

     end 

     Savg(count, :) = mean(S, 1); 
     Ssmooth(count, :) = smooth(Savg(count,:), 'moving'); 
     count = count + 1; 
    end 
    output = Ssmooth; 
end 
+1

你有什麼問題?你試過什麼了?如果您不提供任何詳細信息,我們無法知道如何幫助您。 – MrAzzaman

+0

我添加了一些更多的細節。我的錯。 – Paul

回答

1

看起來不錯其實。

您也可以試試circshift(fft(xFrame(i, :)),[1,a])實現shiftRight,circshift(fft(xFrame(i, :)),[1,-a])得到shiftLeft。請注意,這裏的a是整數,表示您希望移動的xFrame(i, :)中的元素,並且對應於頻率域中的Fs*a,其中Fs是您的採樣率。

+0

你的意思是用circshift移動xFrame(i,:)的fft嗎? – Paul

+0

是和更新,thx – lennon310

0

您嘗試的譜相關估計方法是我稱之爲譜相關估計的時間平滑方法或TSM。您發佈的代碼無法提供正確的答案,除非在一些微不足道的情況下(例如alpha = 0)。原因是您需要通過複雜的相位因子調整每個幀的循環週期圖,以補償每個數據塊爲它之前的版本的延遲版本。

如果更換線

S(I,:) =(1/samplesPerFrame)* shiftLeft *綴(shiftRight)。;

與兩行

S(I,:) =(1/samplesPerFrame)* shiftLeft *綴(shiftRight)。; S(i,:) = S(i,:) * exp(-1i * 2 * pi * alpha * i * samplesPerFrame);其中,

您可以估算SCF。我通過將原始代碼和修改後的代碼應用於比特率(標準化)爲1/10的BPSK信號來證實了這一點。在這種情況下,alpha中循環中的一個alpha值將與1/10的真實循環頻率完全一致。只有修改後的代碼才能爲比特率週期頻率提供正確的SCF。

請參閱我的博客cyclostationary.wordpress.com以獲取更多詳細信息和示例。特別是,我在TSM上發佈了一篇文章 http://cyclostationary.blog/2015/12/18/csp-estimators-the-time-smoothing-method。 (更正了此鏈接5/2/17。)