Compute the Fourier Transform of a square wave from 1 to 1 a

Compute the Fourier Transform of a square wave from -1 to 1 and plot in Mat lab. Verify your answer with the built in function fat.

Solution

disp(\'FOURIER SERIES * SQUARE *)

disp(\'a0+(sum of n=1 upto inf)(an(sin(2pi(n))+bn(cos(2pi(n))\')
disp(\'sen(2*pi*t)\')
n=input(\'INteger=\');
t=input(\'Time interval=\');
j=input(\'INDICATE THE INITIAL TIME INTERVAL=\');
k=input(\'INDICATE FINAL TIME INTERVAL=\');
d=length(t);
a0=k-j;
t=t/100;
f = ones(1,d)*a0;
for i = 1:2:n
fx=sym(\'sin(2*pi*t)\');
an=2*(int(fx,j,k));
an=subs(an);
an=an*(1/i);
f= f+ an*sin(2*pi*i*t);

end
plot(t,f)
%%
disp(\'FOURIER SERIES * TRIANGLE *\')
disp(\'a0+(Sum of n=1 upto inf)(an(sin(2pi(n))+bn(cos(2pi(n))\')
disp(\'sen(2*pi*t)\')
n=input(\'INteger=\');
t=input(\'Time interval=\');
j=input(\'INDICATE THE INITIAL TIME INTERVAL=\');
k=input(\'INDICATE FINAL TIME INTERVAL=\');
d=length(t);
a0=k-j;
t=t/100;
f = ones(1,d)*a0;
for i = 1:2:n
fx=sym(\'sin(2*pi*t)\');
an=2*(int(fx,j,k));
an=subs(an);
an=an*(1/i);
f= f+ an*sin(2*pi*i*t);

end
plot(t,f)

 Compute the Fourier Transform of a square wave from -1 to 1 and plot in Mat lab. Verify your answer with the built in function fat.Solutiondisp(\'FOURIER SERIE

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site