我試圖實現一個譜相關函數來繪製與衝浪功能。 我想我理解SCF的想法,正如我讀過的論文中所描述的那樣,但我在Matlab中實現我的功能時遇到了困難。我一直在以下這些指示:在Matlab中移動信號的FFT
我主要遇到問題妥善轉移我的數據塊。有沒有簡單的方法來實現第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
你有什麼問題?你試過什麼了?如果您不提供任何詳細信息,我們無法知道如何幫助您。 – MrAzzaman
我添加了一些更多的細節。我的錯。 – Paul