簡體   English   中英

在Matlab中移位信號的FFT

[英]Shifting the FFT of a signal in Matlab

我正在嘗試實現頻譜相關函數以使用surf函數進行繪圖。 我想我了解我讀過的一篇論文中描述的SCF的概念,但是在Matlab中實現我的功能時遇到了麻煩。 我一直遵循以下指示:

偽代碼

我大部分都無法正確轉移我的數據。 有沒有簡單的方法可以完成步驟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

實際上看起來不錯。

您也可以嘗試circshift(fft(xFrame(i, :)),[1,a])來獲取shiftRight ,並circshift(fft(xFrame(i, :)),[1,-a]) shiftRightcircshift(fft(xFrame(i, :)),[1,-a])來獲取shiftLeft 請注意,這里的a是整數,表示您要移動的xFrame(i, :)中的元素,並且對應於頻域中的Fs*a ,其中Fs是您的采樣率。

您正在嘗試的頻譜相關估計方法就是我所說的頻譜相關估計的時間平滑方法或TSM。 您發布的代碼無法提供正確的答案,除非在某些瑣碎的情況下(例如alpha = 0)。原因是您需要通過復雜的相位因數來調整每個幀的循環周期圖,以補償每個數據塊都是一個之前版本的延遲版本。

如果您更換線

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

兩行

S(i,:) =(1 / samplesPerFrame)。* shiftLeft。* conj(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。)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM