fftshift isn't workig

9 vues (au cours des 30 derniers jours)
Vitali Pomanitski
Vitali Pomanitski le 8 Juil 2020
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.

Réponse acceptée

Vitali Pomanitski
Vitali Pomanitski le 10 Juil 2020
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.)

Plus de réponses (0)

Catégories

En savoir plus sur Fourier Analysis and Filtering dans Help Center et File Exchange

Tags

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by