Professional Documents
Culture Documents
Objetivos:
Implementing Fourier Series in Matlab.
Marco Teórico:
Metodología y equipos:
Procedimiento
Resultados
EXERCISE 1
● Consider a periodic signal 𝒙(𝒕), with fundamental Period 𝑻 = 𝟐, that is expressed
as:
Código matlab:
%%TALLER
%%Ejercicio 1
%%Grafico
figure(1)
t1=0:0.01:6;
f=@(t1) (heaviside(t1)-heaviside(t1-1));
x=f(mod(t1,2));
plot(t1,x)
xlabel('t')
ylabel('x(t)')
% SERIES DE FOURIER
syms t
T=2;
w0=(2*pi)/T;
f=heaviside(t)-heaviside(t-1);
% DC COMPONENT
a0_syms=(1/T)*int(f,t,0,T)
a0=double(a0_syms)
fnum=a0;
tnum=0:0.01:6;
% AK AND BK
figure (2)
for k=1:1:10;
ak_syms(k)=(2/T)*int(f*cos(w0*k*t),t,0,T);
bk_syms(k)=(2/T)*int(f*sin(w0*k*t),t,0,T);
ak(k)=double(ak_syms(k));
bk(k)=double(bk_syms(k));
fharmonic=ak(k)*cos(w0*k*tnum)+bk(k)*sin(w0*k*tnum);
fnum=fharmonic+fnum;
plot(tnum,fnum)
end
● What’s the value of the DC component of the signal?
RTA//
% DC COMPONENT
a0_syms=(1/T)*int(f,t,0,T)
a0=double(a0_syms)
fnum=a0;
tnum=0:0.01:6;
● Express the signal as a Fourier Series as an infinite sum of sines and cosines.
RTA//
% AK AND BK
figure (2)
for k=1:1:10;
ak_syms(k)=(2/T)*int(f*cos(w0*k*t),t,0,T);
bk_syms(k)=(2/T)*int(f*sin(w0*k*t),t,0,T);
ak(k)=double(ak_syms(k));
bk(k)=double(bk_syms(k));
fharmonic=ak(k)*cos(w0*k*tnum)+bk(k)*sin(w0*k*tnum);
fnum=fharmonic+fnum;
plot(tnum,fnum)
end
EXERCISE 2
● Consider a periodic signal 𝒙(𝒕), with fundamental Period 𝑻 = 𝟐, that is expressed
as:
RTA//
Código matlab:
%%Ejercicio 2
%%Grafico
figure(1)
t1=0:0.01:6;
f=@(t1)(t1.*(heaviside(t1)-heaviside(t1-1)));
x=f(mod(t1,2));
plot(t1,x)
xlabel('t')
ylabel('x(t)')
% SERIES DE FOURIER
syms t
T=2;
w0=(2*pi)/T;
f=t.*(heaviside(t)-heaviside(t-1));
% DC COMPONENT
a0_syms=(1/T)*int(f,t,0,T)
a0=double(a0_syms)
fnum=a0;
tnum=0:0.01:6;
% AK AND BK
figure (2)
for k=1:1:100;
ak_syms(k)=(2/T)*int(f*cos(w0*k*t),t,0,T);
bk_syms(k)=(2/T)*int(f*sin(w0*k*t),t,0,T);
ak(k)=double(ak_syms(k));
bk(k)=double(bk_syms(k));
fharmonic=ak(k)*cos(w0*k*tnum)+bk(k)*sin(w0*k*tnum);
fnum=fharmonic+fnum;
plot(tnum,fnum)
end
a0_syms=(1/T)*int(f,t,0,T)
a0=double(a0_syms)
fnum=a0;
tnum=0:0.01:6;
● Express the signal as a Fourier Series as an infinite sum of sines and cosines.
RTA//
% AK AND BK
figure (2)
for k=1:1:100;
ak_syms(k)=(2/T)*int(f*cos(w0*k*t),t,0,T);
bk_syms(k)=(2/T)*int(f*sin(w0*k*t),t,0,T);
ak(k)=double(ak_syms(k));
bk(k)=double(bk_syms(k));
fharmonic=ak(k)*cos(w0*k*tnum)+bk(k)*sin(w0*k*tnum);
fnum=fharmonic+fnum;
plot(tnum,fnum)
end