Está en la página 1de 21

%Se limpia el sistema

clear all, clf,clc


%Se define el intervalo de t
t=0:0.001:1;
A=1;
y=(A/2);
cn=(A/pi);
y1=y-cn*sin(2*pi*t);
%ahora subdividiremos la pantalla con el comando subplot en 4x4
subplot (4,4,1)
plot(t,y1)
title('Fundamental')
xlabel('Tiempo')
ylabel('f(t)')
grid
axis([-0.5 1.5 -0.5 1.5])
%SEGUNDA COMPONENTE
y2=-(cn/2)*sin(4*pi*t);
subplot(4,4,2)
plot(t,y2)
title('f2')
xlabel('Tiempo')
ylabel('f(t)')
grid
axis([-0.5 1.5 -0.5 1.5])
%SUMA DE LAS COMPONENTES ANTERIORES
yt1=y1+y2;
subplot(4,4,3)
plot(t,yt1)
title('Fundamental+f2')
xlabel('Tiempo')
ylabel('f(t)')
grid
axis([-0.5 1.5 -0.5 1.5])

%Tercera componente
y3=-(cn/3)*sin(6*pi*t);
subplot(4,4,6)
plot(t,y3)
title('f3')
xlabel('Tiempo')
ylabel('f(t)')
grid
axis([-0.5 1.5 -0.5 1.5])
%SUMA DE FUNDAMENTAL+f2+f3
yt3=yt1+y3;
subplot(4,4,7)
plot(t,yt3)
title('Fundamental+f2+f3')
xlabel('Tiempo')
ylabel('f(t)')
grid
axis([-0.5 1.5 -0.5 1.5])
%CUARTA COMPONENTE y4
y4=(-cn/4)*sin(8*pi*t);
subplot(4,4,10)
plot(t,y4)
title('f4')
xlabel('Tiempo')
ylabel('f(t)')
grid
axis([-0.5 1.5 -0.5 1.5])
%SUMA DE FUNDAMENTAL+f2+f3+f4
yt4=yt3+y4;
subplot(4,4,11)
plot(t,yt4)
title('Fundamental+f3+f2+f4')
xlabel('Tiempo')
ylabel('f(t)')
grid
axis([-0.5 1.5 -0.5 1.5])
%QUINTA COMPONENTE f5
y5=(-cn/5)*sin(10*pi*t);
subplot(4,4,14)
plot(t,y5)
title('f5')
xlabel('Tiempo')
ylabel('f(t)')
grid
axis([-0.5 1.5 -0.5 1.5])
%SUMA DE FUNDAMENTAL f2+f3+f4+f5
yt5=yt4+y5;
subplot(4,4,15)
plot(t,yt5)
title('Fundamental f2+f3+f4+f5')

xlabel('Tiempo')
ylabel('f(t)')
grid
axis([-0.5 1.5 -0.5 1.5])
%ORIGINAL
x=A*t;
subplot(4,4,16)
plot(t,x)
title('Original')
xlabel('Tiempo')
ylabel('f(t)')
grid
axis([-0.5 1.5 -0.5 1.5])

%Se limpia el sistema


clear all, clf,clc
%Se define el intervalo de tiempo, as como la resolucin para t
t=-4:0.001:4;
%Se indica el valor de la amplitud de la recta (o pendiente)
A=4;
%Valor de C.D. para la S.T.F. de la recta
y=(A/2);
%Valor de la bn de la S.T.F. de la recta, definida como cn
cn=(A/pi);
%FUNDAMENTAL y1
y1=y-cn*sin(2*pi*t);
%Se divide la pantalla en 4x4 y se coloca la grfica en la posicin 1
subplot (4,4,1)
plot(t,y1)
title('Fundamental')
xlabel('Tiempo')
ylabel('f(t)')
grid
axis([-4.5 4.5 -0.8 4.5])
%SEGUNDA COMPONENTE y2
y2=-(cn/2)*sin(4*pi*t);
%Se divide la pantalla en 4x4 y se coloca la grfica en la posicin 2
subplot(4,4,2)
plot(t,y2)
title('f2')
xlabel('Tiempo')
ylabel('f(t)')
grid
axis([-4.5 4.5 -0.8 4.5])
%SUMA DE LAS COMPONENTES ANTERIORES yt1=y1+yw

yt1=y1+y2;
%Se divide la pantalla en 4x4 y se coloca la grfica en la posicin 3
subplot(4,4,3)
plot(t,yt1)
title('Fundamental+f2')
xlabel('Tiempo')
ylabel('f(t)')
grid
axis([-4.5 4.5 -0.8 4.5])
%TERCERA COMPONENTE y3
y3=-(cn/3)*sin(6*pi*t);
%Se divide la pantalla en 4x4 y se coloca la grfica en la posicin 6
subplot(4,4,6)
plot(t,y3)
title('f3')
xlabel('Tiempo')
ylabel('f(t)')
grid
axis([-4.5 4.5 -0.8 4.5])

%SUMA DE FUNDAMENTAL+f2+f3
yt3=yt1+y3;
%Se divide la pantalla en 4x4 y se coloca la grfica en la posicin 7
subplot(4,4,7)
plot(t,yt3)
title('Fundamental+f2+f3')
xlabel('Tiempo')
ylabel('f(t)')
grid
axis([-4.5 4.5 -0.8 4.5])
%CUARTA COMPONENTE y4
y4=(-cn/4)*sin(8*pi*t);
%Se divide la pantalla en 4x4 y se coloca la grfica en la posicin 10
subplot(4,4,10)
plot(t,y4)
title('f4')
xlabel('Tiempo')
ylabel('f(t)')
grid
axis([-4.5 4.5 -0.8 4.5])
%SUMA DE FUNDAMENTAL+f2+f3+f4
yt4=yt3+y4;
%Se divide la pantalla en 4x4 y se coloca la grfica en la posicin 11
subplot(4,4,11)
plot(t,yt4)
title('Fundamental+f3+f2+f4')
xlabel('Tiempo')
ylabel('f(t)')
grid
axis([-4.5 4.5 -0.8 4.5])
%QUINTA COMPONENTE

%Se divide la pantalla en 4x4 y se coloca la grfica en la posicin 14


y5=(-cn/5)*sin(10*pi*t);
%Se divide la pantalla en 4x4 y se coloca la grfica en la posicin 14
subplot(4,4,14)
plot(t,y5)
title('f5')
xlabel('Tiempo')
ylabel('f(t)')
grid
axis([-4.5 4.5 -0.8 4.5])
%SUMA DE FUNDAMENTAL f2+f3+F4+F5
yt5=yt4+y5;
%Se divide la pantalla en 4x4 y se coloca la grfica en la posicin 15
subplot(4,4,15)
plot(t,yt5)
title('Fundamental f2+f3+f4+f5')
xlabel('Tiempo')
ylabel('f(t)')
grid
axis([-4.5 4.5 -0.8 4.5])
%ORIGINAL
%Se define un tiempo diferente a t, denominado t1, que se utilizar slo
para la original. Consiste en una serie de nmeros que al unirse con el
comando plot a la variable x, tambin declarada como nmeros, generarn
una serie de coordenadas que muestran a la funcin original
t1=[-4 -3 -3 -2 -2 -1 -1 0 0 1 1 2 2 3 3 4 4];
x=[0 4 0 4 0 4 0 4 0 4 0 4 0 4 0 4 0];
%Se divide la pantalla en 4x4 y se coloca la grfica en la posicin 16
subplot(4,4,16)
plot(t1,x)
title('Original')
xlabel('Tiempo')
ylabel('f(t)')
grid
axis([-4.5 4.5 -0.8 4.5])

%Primero se limpiar todo el sistema


clear all, clf, clc
%Despus definimos cuantos trminos se tendrn en la serie
n=5;
%ahora definimos inicio y terminacin
t=0:0.001:1;
A=1;
y=(A/2);
%Se hace un vector y se rellena de ceros
x=zeros(size(t));
hold on %Se escribe comando de sujecin
%Se inicia el ciclo reiterativo
for n=1:1:n
cn=(A/(n*pi));
y1=-cn*sin(2*n*pi*t);
x=y+y1+x;
plot(t,x)
x=x-y;
end
title('Aproximacin con cinco trminos')
xlabel('t')
ylabel('f(t)')
hold off
grid
axis ([0 1 -0.1 1.1])

%Se limpia el sistema


clear all, clf, clc
%Nmero de trminos de la serie
n=5;
%Se define el intervalo de tiempo, as como la resolucin para t
t=-2:0.001:2
%Se define la amplitud la recta original
A=1;
%Se define el valor de C.D. de la S.T.F. a0, declarada como y
y=(A/2);
%Se hace un vector y se rellena de ceros
x=zeros(size(t));
%Comando de sujecin de grfica
hold on
%Se inicia el ciclo reiterativo
for n=1:1:n
%Se define el valor de bn, declarndola como cn
cn=(A/(n*pi));
y1=-cn*sin(2*n*pi*t);
%Se declara la variable x, suma de las componentes que componen a la
original
x=y1+x;
%Se grafica x ms la componente de C.D.
plot(t,x+y)
end
title('Aproximacin con cinco trminos')
xlabel('t')
ylabel('f(t)')
hold off
grid
axis ([-2.1 2.1 -0.1 1.1])

%Primero se limpiar todo el sistema


clear all, clf, clc
%Despus definimos cuantos trminos se tendrn en la serie
n=55;
t=0:0.001:1;%ahora definimos inicio y terminacin
A=1;
y=(A/2);
%Se hace un vector y se rellena de ceros
x=zeros(size(t));
for n=1:1:n %Se inicia el ciclo reiterativo
cn=(A/(n*pi));
y1=-cn*sin(2*n*pi*t);
x=y+y1+x;
plot(t,x)
x=x-y;
end
title('Aproximacin con 55 trminos')
xlabel('t')
ylabel('f(t)')
grid
axis ([0 1 -0.1 1.1])

%Se limpiar todo el sistema


clear all, clf, clc
%Nmero de trminos de la S.T.F
n=55;
%Se define el intervalo de tiempo, as como la resolucin para t
t=-1:0.001:2;
%Se define la amplitud la recta original
A=7;
%Se define el valor de C.D. de la S.T.F. a0, declarada como y
y=(A/2);
%Se hace un vector y se rellena de ceros
x=zeros(size(t));
%Se inicia el ciclo reiterativo
for n=1:1:n
%Se define el valor de bn, declarndola como cn
cn=(A/(n*pi));
%S.T.F. con n trminos
y1=-cn*sin(2*n*pi*t);
%Se declara la variable x, suma de las componentes que componen a la
original
x=y1+x;
plot(t,x+y)
end
title('Aproximacin con 205 trminos')
xlabel('t')
ylabel('f(t)')
grid
axis ([-1.2 2.2 -1 8])

%Primero se limpiara todo el sistema


clear all, clf,clc
%Se define el perodo T=1/2
t=0:0.001:0.5;
%Se definen las constantes a0, an y bn, de la Serie Trigonomtrica de
%Fourier
a0=0.79;
an=((0.79*2)/(1+((4*pi).^2)));
bn=((0.79*8*pi)/(1+((4*pi).^2)));
%Fundamental
y1=a0+an*(cos(4*pi*t))+bn*(sin(4*pi*t));
%Se subdivide la pantalla en 4x4 cuadros y se coloca la grfica en el
%primer cuadro
subplot (4,4,1)
plot(t,y1)
title('Fundamental')
ylabel('f(t)')
xlabel('Tiempo')
grid
%SEGUNDA COMPONENTE y2
%Se definen las constantes an1 y bn1, de la Serie Trigonomtrica de
%Fourier para la segunda componente, donde n=2
an1=((0.79*2)/(1+((4*2*pi).^2)));
bn1=((0.79*8*pi*2)/(1+((4*2*pi).^2)));
%Segunda componente
y2=an1*(cos(4*2*pi*t))+bn1*(sin(4*2*pi*t));
subplot(4,4,2)
plot(t,y2)
title('f2')
xlabel('Tiempo')
ylabel('f(t)')
grid
%SUMA DE LA FUNDAMENTAL+f2

yt1=y1+y2;
subplot(4,4,3)
plot(t,yt1)
title('Fundamental+f2')
ylabel('f(t)')
xlabel('Tiempo')
grid
%TERCERA COMPONENTE y3
%Se definen las constantes an2 y bn2, de la Serie Trigonomtrica de
%Fourier para la tercera componente, donde n=3
an2=((0.79*2)/(1+((4*3*pi).^2)));
bn2=((0.79*8*pi*3)/(1+((4*3*pi).^2)));
%Tercera componente
y3=an2*(cos(4*3*pi*t))+bn2*(sin(4*3*pi*t));
subplot(4,4,6)
plot(t,y3)
title('f3')
xlabel('Tiempo')
ylabel('f(t)')
grid
%SUMA DE FUNDAMENTAL+f2+f3
yt3=yt1+y3;
subplot(4,4,7)
plot(t,yt3)
title('Fundamental+f2+f3')
xlabel('Tiempo')
ylabel('f(t)')
grid
%CUARTA COMPONENTE y4
%Se definen las constantes an3 y bn3, de la Serie Trigonomtrica de
%Fourier para la cuarta componente, donde n=4
an3=((0.79*2)/(1+((4*4*pi).^2)));
bn3=((0.79*8*pi*4)/(1+((4*4*pi).^2)));
%Cuarta componente
y4=an2*(cos(4*4*pi*t))+bn2*(sin(4*4*pi*t));
subplot(4,4,10)
plot(t,y4)
title('f4')
xlabel('Tiempo')
ylabel('f(t)')
grid
%SUMA DE FUNDAMENTAL+f2+f3+f4
yt4=yt3+y4;
subplot(4,4,11)
plot(t,yt4)
title('Fundamental+f2+f3+f4')
ylabel('f(t)')
grid
%QUINTA COMPONENTE y5
%Se definen las constantes an4 y bn4, de la Serie Trigonomtrica de
%Fourier para la quinta componente, donde n=5

an5=((0.79*2)/(1+((4*5*pi).^2)));
bn5=((0.79*8*pi*5)/(1+((4*5*pi).^2)));
%Quinta componente
y5=an2*(cos(4*5*pi*t))+bn2*(sin(4*5*pi*t));
subplot(4,4,14)
plot(t,y5)
title('f5')
xlabel('Tiempo')
ylabel('f(t)')
grid
%SUMA DE FUNDAMENTAL f2+f3+f4+f5
yt5=yt4+y5;
subplot(4,4,15)
plot(t,yt5)
title('Fundamental f2+f3+f4+f5')
ylabel('f(t)')
grid
%FUNCIN ORIGINAL f(t), representacin original
x=exp(-t);
subplot(4,4,16)
plot(t,x)
title('Original')
xlabel('Tiempo')
ylabel('f(t)')
grid
axis([-0.01 0.51 -0.01 1.05])

%Primero se limpiara todo el sistema


clear all, clf,clc
%Se define el tiempo en el que se ubica la grfica
t=0.5:0.001:2.5;
%Se definen las constantes a0, an y bn
a0=0.79;
an=((0.79*2)/(1+((4*pi).^2)));
bn=((0.79*8*pi)/(1+((4*pi).^2)));
%Fundamental
y1=a0+an*(cos(4*pi*t))+bn*(sin(4*pi*t));
%Se divide la ventana en 4x4 y se coloca la grfica en el primer recuadro
subplot (4,4,1)
plot(t,y1)
title('Fundamental')
ylabel('f(t)')
xlabel('Tiempo')
grid
%SEGUNDA COMPONENTE
%Se definen las constantes an1 y bn1
an1=((0.79*2)/(1+((4*2*pi).^2)));
bn1=((0.79*8*pi*2)/(1+((4*2*pi).^2)));
%Segunda componente
y2=an1*(cos(4*2*pi*t))+bn1*(sin(4*2*pi*t));
%Se divide la ventana en 4x4 y se coloca la grfica en el segundo
recuadro
subplot(4,4,2)
plot(t,y2)
title('f2')
xlabel('Tiempo')
ylabel('f(t)')
grid
%SUMA DE LAS COMPONENTES ANTERIORES
yt1=y1+y2;
%Se divide la ventana en 4x4 y se coloca la grfica en el tercer recuadro
subplot(4,4,3)
plot(t,yt1)
title('Fundamental+f2')

ylabel('f(t)')
xlabel('Tiempo')
grid
%Tercera componente
%Se definen las constantes an2 y bn2
an2=((0.79*2)/(1+((4*3*pi).^2)));
bn2=((0.79*8*pi*3)/(1+((4*3*pi).^2)));
%Tercera componente
y3=an2*(cos(4*3*pi*t))+bn2*(sin(4*3*pi*t));
%Se divide la ventana en 4x4 y se coloca la grfica en el sexto recuadro
subplot(4,4,6)
plot(t,y3)
title('f3')
xlabel('Tiempo')
ylabel('f(t)')
grid
%SUMA DE FUNDAMENTAL+f2+f3
yt3=yt1+y3;
%Se divide la ventana en 4x4 y se coloca la grfica en el sptimo
recuadro
subplot(4,4,7)
plot(t,yt3)
title('Fundamental+f2+f3')
xlabel('Tiempo')
ylabel('f(t)')
grid
%CUARTA COMPONENTE y4
%Se definen las constantes an3 y bn3
an3=((0.79*2)/(1+((4*4*pi).^2)));
bn3=((0.79*8*pi*4)/(1+((4*4*pi).^2)));
%Cuarta componente
y4=an3*(cos(4*4*pi*t))+bn3*(sin(4*4*pi*t));
%Se divide la ventana en 4x4 y se coloca la grfica en el dcimo recuadro
subplot(4,4,10)
plot(t,y4)
title('f4')
xlabel('Tiempo')
ylabel('f(t)')
grid

%SUMA DE FUNDAMENTAL+f2+f3+f4
yt4=yt3+y4;
%Se divide la ventana en 4x4 y se coloca la grfica en el onceavo
recuadro
subplot(4,4,11)
plot(t,yt4)
title('Fundamental+f2+f3+f4')
ylabel('f(t)')
grid

%QUINTA COMPONENTE f5
%Se definen las constantes an4 y bn4
an4=((0.79*2)/(1+((4*5*pi).^2)));
bn4=((0.79*8*pi*5)/(1+((4*5*pi).^2)));
%Quinta componente
y5=an4*(cos(4*5*pi*t))+bn4*(sin(4*5*pi*t));
%Se divide la ventana en 4x4 y se coloca la grfica en el catorceavo
recuadro
subplot(4,4,14)
plot(t,y5)
title('f5')
xlabel('Tiempo')
ylabel('f(t)')
grid
%SUMA DE FUNDAMENTAL f2+f3+f4+f5
yt5=yt4+y5;
%Se divide la ventana en 4x4 y se coloca la grfica en el quinceavo
recuadro
subplot(4,4,15)
plot(t,yt5)
title('Fundamental f2+f3+f4+f5')
ylabel('f(t)')
grid
%ORIGINAL
t1=0:0.001:0.5;
x=exp(-t1);
%Se divide la ventana en 4x4 y se coloca la grfica en el dieciseisavo
recuadro
subplot(4,4,16)
plot(t1,x)
title('Original')
xlabel('Tiempo')
ylabel('f(t)')
grid
axis([-0.01 0.51 -0.01 1.05])

%Primero se limpiar todo el sistema


clear all, clf, clc
%Se define el intervalo en el que se representa la funcin con T=0.5 y
resolucin
t=0:0.001:0.5;
%Se define el trmino de C.D. a0
a0=0.79;
%Se define el nmero de trminos que tendr la funcin
n=5;
%Se hace un vector y se rellena de ceros
x=zeros(size(t));
%Se escribe comando de sujecin
hold on
%Se inicia el ciclo reiterativo
for n=1:1:n
%Se declaran las componentes an y bn
an=((0.79*2)/(1+((4*n*pi).^2)))*cos(4*n*pi*t);
bn=((0.79*8*pi*n)/(1+((4*n*pi).^2)))*sin(4*n*pi*t);
%Se declara la variable x, suma de las componentes que componen a la
original
x=an+bn+x;
%Se grafica x ms la componente de C.D.
plot(t,x+a0)
end
title('Aproximacin con cinco trminos')
xlabel('t')
ylabel('f(t)')
hold off
grid

%Primero se limpiar todo el sistema


clear all, clf, clc
%Se define el intervalo en el que se representa la funcin con T=0.5 y
resolucin
t=-0.5:0.001:2.5;
%Se define el trmino de C.D. a0
a0=0.79;
%Se define el nmero de trminos que tendr la funcin
n=7;
%Se hace un vector y se rellena de ceros
x=zeros(size(t));
%Se escribe comando de sujecin
hold on
%Se inicia el ciclo reiterativo, for(donde inicia:incrementos:condicin
%final
for n=1:1:n
%Se declaran las componentes an y bn
an=((0.79*2)/(1+((4*n*pi).^2)))*cos(4*n*pi*t);
bn=((0.79*8*pi*n)/(1+((4*n*pi).^2)))*sin(4*n*pi*t);
%Se declara la variable x, suma de las componentes que componen a la
original
x=an+bn+x;
%Se grafica x ms la componente de C.D.
plot(t,x+a0)
end
title('Aproximacin con siete trminos')
xlabel('t')
ylabel('f(t)')
hold off
grid

%Primero se limpiar todo el sistema


clear all, clf, clc
%Despus definimos cuantos trminos se tendrn en la serie
n=55;
t=0:0.001:0.5;%ahora definimos inicio y terminacin
a0=0.79;
%Se hace un vector y se rellena de ceros
x=zeros(size(t));
for n=1:1:n %Se inicia el ciclo reiterativo
an=(0.79*2)/(1+((4*n*pi).^2));
ancos=an*cos(4*n*pi*t);
bn=(0.79*8*pi*n)/(1+((4*n*pi).^2));
bnsen=bn*sin(4*n*pi*t);
x=ancos+bnsen+x;
end
plot(t,x+a0)
title('Aproximacin con 55 trminos')
xlabel('t')
ylabel('f(t)')
grid
axis([-0.01 0.51 0 1.1])

Aproximacin con 395 trminos


1.2

f(t)

0.8

0.6

0.4

0.2

0
-0.5

0.5

1.5
t

2.5

3.5

%Limpieza del sistema


clear all, clf, clc
%Nmero de trminos de la serie a evaluar
n=395;
%Se define el intervalo de representacin de la serie en tiempo, eje x
t=-0.5:0.001:3.5;
%Se define el valor de componente C.D. a0
a0=0.79;
%Se hace un vector y se rellena de ceros
x=zeros(size(t));
%Se inicia el ciclo reiterativo
for n=1:1:n
%Se definen las variables an y bn, as como las funciones ancos y bncos
an=(0.79*2)/(1+((4*n*pi).^2));
ancos=an*cos(4*n*pi*t);
bn=(0.79*8*pi*n)/(1+((4*n*pi).^2));
bnsen=bn*sin(4*n*pi*t);
%Se suman las componentes
x=ancos+bnsen+x;
end
%Se grafica la x resultante, ms la suma de la componente de C.D.
plot(t,x+a0)
title('Aproximacin con 395 trminos')
xlabel('t')
ylabel('f(t)')
grid
axis([-0.51 3.51 0 1.3])

También podría gustarte