fourier transform of a rect function
조회 수: 25 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (1개)
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;
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!