fourier transform of a rect function
25 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Image Analyst
am 18 Mär. 2018
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 Kommentare
Siehe auch
Kategorien
Mehr zu Discrete Fourier and Cosine Transforms 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!