FFT of Rectangular Window
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I want to calculate the phase of a Rectangular window with width T and shifted by T0. I was expecting the slope of the phase to be -T0. Unfortunately, I am getting the slope as -(T0 - T/2). Can someone explain the mistake in my code attached.
T0 = 50;
T = 20;
x = (0:0.1:100);
y = 1 * (x>=(T0 - T/2) & x <= (T0 + T/2));
N = 2 ^ nextpow2(length(x));
Fs = 1/mean(diff(x));
w_axis = linspace(0, Fs, N) * 2 * pi;
fft_y = fft(y, N);
ang = unwrap(angle(fft_y));
mag = abs(fft_y);
index = 1:N/2;
mag = mag(index);
ang = ang(index);
w_axis = w_axis(index);
subplot(2, 2, [2, 4]);plot(x, y);
subplot(2, 2, 1);plot(w_axis, mag);
subplot(2, 2, 3);plot(w_axis, ang);
p = polyfit(w_axis, ang, 1);
fprintf('Slope of phase = %3.3f\n', p(1));
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Spectral Measurements finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!