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.)
fftshift isn't workig
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Vitali Pomanitski
am 8 Jul. 2020
Beantwortet: Vitali Pomanitski
am 10 Jul. 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.
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Fourier Analysis and Filtering finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!