fftshift isn't workig

9 ビュー (過去 30 日間)
Vitali Pomanitski
Vitali Pomanitski 2020 年 7 月 8 日
回答済み: Vitali Pomanitski 2020 年 7 月 10 日
Hi,
I successfully got two deltas on 4/10 and on 2/10, but I cannot center the graph.
Could you help me?
t = 0:(1/fs):(10-1/fs);
S = 2*cos(3*pi*t/10).*cos(pi*t/10); %cos(4pit/10)+cos(2pit/10)
n = length(S);
X = fft(S);
f = (0:n-1)*(fs/n)*2; %multiply by pi*2, leave the pi aside
f80 = (0:n-1);
power = abs(X).^2/n;
stem(f,power)
Y = fftshift(X)
fshift = (-n/2:n/2-1)*(fs/n)
powershift = abs(Y).^2/n;
plot(fshift,powershift)
I attached pictures. In the second graph those are not even deltas.

採用された回答

Vitali Pomanitski
Vitali Pomanitski 2020 年 7 月 10 日
I found the solution, I didn't post the frequency of sampling. But apparently fftshift just swaps X axis and then if there were no 0 between samples they get joined. So I had to add zeroes to the fft result in order for the fftshift to work properly, this is by extending the sampled rate of the original function. (Making sampling frequency higher extends repeating time in frequency domain vice versa making sampled range larger adds samples to the frequency domain in between the existing samples.)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFourier Analysis and Filtering についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by