fourier transform of a rect function

조회 수: 25 (최근 30일)
justin stephens
justin stephens 2018년 3월 18일
편집: Walter Roberson 2018년 3월 18일
i am having some issues with trying to compute the Fourier transform of a rectangular function.
the period is 4 and i am trying to use the trigonometric representation of the fourier series to calculate it. my a0=1/2, ak= (sin((k*pi)/2)/k*pi) and the final result should be this. N= 10
here is the code i have written but it does not give the wave form that i would expect.
function x= fs(N)
t= -5:.1:5;
T=4;
w=(2*pi)/T;
a0=1/2;
for k=1:2:N
ak=sin((k*pi)/2)/(k*pi);
x=a0+2*abs(ak)*cos(k*w*t);
end
plot(t,x)
Any help would be greatly appreciated.

답변 (1개)

Image Analyst
Image Analyst 2018년 3월 18일
Try this:
t= -5:.1:5;
T=4;
w=(2*pi)/T;
a0=1/2;
x = a0;
for k=1:N
ak = sin((k*pi)/2)/(k*pi);
x = x + 2*abs(ak)*cos(k*w*t);
end
plot(x);
grid on;

카테고리

Help CenterFile Exchange에서 Discrete Fourier and Cosine Transforms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by