FFT of Rectangular Window

조회 수: 4 (최근 30일)
Anand Chandrasekhar
Anand Chandrasekhar 2019년 2월 24일
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개)

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by