INFORME N1
P1) Generar las siguientes seales peridicas en Matlab y graficarlas. Para cada grfica se debe aadir la
leyenda, las etiquetas de cada variable y el ttulo de la grfica. El nmero de puntos de cada grafica es
diferente.
a )v(t ) v
n
p (t (7 m)n); 2 t ( ms) 16
t 1 1 t (ms) 0
t 0 t (ms ) 2
con : v p
2 2 t (ms) 3
0 t (ms ) 3
b)r (t ) r (t (10m)n); 5 t (ms) 25
n
p
Solucin:
a) Debido a la definicin de v(t) entre -2 y 16, se considera 7n desde -7 a 14 pues solo estos valores de
7n influyen en el tiempo definido para v(t):
clc;close all;clear;
t=-2:0.00001:16; %tiempo en el que esta definido v(t)
L=numel(t); %numero de elementos de t
ntem=-7:7:14; %argumento 7n en v(t)
N=numel(ntem);
vtem=zeros(N,L); %matriz temporal para almacenar cada desplazamiento de v(t)
i=1; %variable de inicializacion
for n=-7:7:14;
tp=t-n; %desplazamiento de t
vp0=0;
vp1=1-tp;
vp2=tp;
vp3=2;
vp4=0;
vp=vp0.*(tp<-1)+ vp1.*(-1<=tp & tp<0)+ vp2.*(0<=tp & tp<2)+ vp3.*(2<=tp &
tp<3)+ vp4.*(3<=tp);
vtem(i,1:L)=vp;
i=i+1;
end
vtot=sum(vtem); %suma cada columna de vtem lo cual nos da la suma de todos los
desplazamientos
plot(t,vtot,'b','LineWidth',2)
axis([-2 16 0 2.2])
title('v(t)','fontsize',16)
xlabel('Tiempo(ms)','fontsize',14)
ylabel('v(t)','fontsize',14)
legend('v(t)')
grid on
b) Debido a la definicin de r(t) entre -5 y 25, se considera 10n entre -10 a 30 pues solo estos valores
de 10n influyen en el tiempo definido para r(t).
clc;close all;clear;
t=-5:0.0001:25; %tiempo en el que esta definido r(t)
L=numel(t); %numero de elementos de t
ntem=-10:10:30; %argumento 10n en r(t)
N=numel(ntem);
rtem=zeros(N,L); %matriz temporal para almacenar cada desplazamiento de r(t)
i=1; %variable de inicializacion
for n=-10:10:30;
tr=t-n; %desplazamiento de t
rp=heaviside(tr+2)-2*heaviside(tr+1)+2*heaviside(tr)-1*heaviside(tr-2)-
2*heaviside(tr-3)+2*heaviside(tr-4);
rtem(i,1:L)=rp;
i=i+1;
end
rtot=sum(rtem); %suma cada columna de rtem lo cual nos da la suma de todos los
desplazamientos
plot(t,rtot,'g','LineWidth',2)
axis([-5 25 -2.1 1.2])
title('r(t)','fontsize',16)
xlabel('Tiempo(ms)','fontsize',14)
ylabel('r(t)','fontsize',14)
legend('r(t)')
grid on
Nota: Se puede observar que tanto en v(t) como en r(t) se obtiene un tren de pulsos de vp(t) y rp(t)
respectivamente con lo cual no es necesario hacer la sumatoria infinita ya que se puede saber
anticipadamente el valor de n mnimo y mximo, para los desplazamientos, usando los tiempos en
los que estn definidos v(t) y r(t).
P2) I) Escribir dos funciones para generar las seales anteriores. Deben aceptar como argumento:
Los tiempos inicial y final para graficar v(t).
El nmero de puntos del intervalo de tiempo.
Debe verificarse que el intervalo sea mayor o igual que el intervalo de vp(t) y rp(t).
La funcin debe entregar el vector de tiempo y amplitud de la seal generada.
II) Usando las funciones anteriores, graficar las seales (t) = 5 v(5t + 3) y q(t) = 2 r(2t + 5). Todas
las unidades de los argumentos de v(t) y q(t) estn en ms.
Solucin:
[t,y]=vpulse(-2,16,10000);
plot(t,y,'b','LineWidth',2)
axis([-2 16 0 2.2])
title('v(t)','fontsize',16)
xlabel('Tiempo(ms)','fontsize',14)
ylabel('v(t)','fontsize',14)
legend('v(t)')
grid on
function [time,y]=rpulse(ti,tf,n)
if ti>-3
error('[time,y]=rpulse(ti,tf,n)--> ti debe ser menor o igual a -3')
elseif tf<6
error('[time,y]=rpulse(ti,tf,n)--> tf debe ser mayor o igual a 6')
elseif n<0
error('[time,y]=rpulse(ti,tf,n)--> n debe ser mayor o igual a 0')
end
t=linspace(ti,tf,n); %tiempo en el que esta definido rpulse
L=numel(t); %numero de elementos de t
ni=fix((ti-6)/10);
nf=fix((tf+3)/10);
ntem=10*(ni-1):10:10*(nf+1); %argumento 7n en v(t)
N=numel(ntem);
rtem=zeros(N,L); %matriz temporal para almacenar cada desplazamiento de
v(t)
i=1; %variable de inicializacion
for n=10*(ni-1):10:10*(nf+1);
tr=t-n;
rp=heaviside(tr+2)-2*heaviside(tr+1)+2*heaviside(tr)-1*heaviside(tr-2)-
2*heaviside(tr-3)+2*heaviside(tr-4);
rtem(i,1:L)=rp;
i=i+1;
end
y=sum(rtem);
time=t;
[t,y]=rpulse(-5,25,10000);
plot(t,y,'g','LineWidth',2)
axis([-5 25 -2.1 1.2])
title('v(t)','fontsize',16)
xlabel('Tiempo(ms)','fontsize',14)
ylabel('v(t)','fontsize',14)
legend('v(t)')
grid on
clear;clc;close all;
%h(t)=5-v(-5t+3)
ti=-2;tf=16;n=100000;
t=linspace(ti,tf,n);
[tw,w]=vpulse(-5*tf+3,-5*ti+3,n);%se intercambia el valor que corresponde a ti
y tf respectivamente
%debido al escalamiento en h(t)
h=5-w;
th=sort(t,'descend');%se reordena t de manera descendente debido al cambio en
el argumento de vpulse
figure(1)
plot(th,h,'b','LineWidth',2);
axis([ti-0.5 tf+0.5 0 5.1])
title('h(t)=5-v(-5t+3)','fontsize',16)
xlabel('Tiempo(ms)','fontsize',14)
ylabel('h(t)','fontsize',14)
legend('h(t)',-1)
grid on
ki=-5;kf=25;N=100000;
tr=linspace(ki,kf,N);
[tb,b]=rpulse(2*ki+5,2*kf+5,N);
q=2-b;
tq=tr;
figure(2)
plot(tq,q,'g','LineWidth',2);
axis([ki-0.5 kf+0.5 0 4.1])
title('q(t)=2-r(2t+5)','fontsize',16)
xlabel('Tiempo(ms)','fontsize',14)
ylabel('q(t)','fontsize',14)
legend('q(t)',-1)
grid on
P3) Encuentre para la seal dada:
x(t ) (1 e j 3t )[u (t 1) u (t 2)]
close all;clc;
%a)Grafica
t=-2:0.0001:3;
z=(1+exp(-1i*3*t));%Datos complejos
g=heaviside(t+1)-heaviside(t-2);%Gate de ancho 3
x=z.*g;
rez=real(z);imz=imag(z);
rex=real(x);imx=imag(x);
%Parte Real
figure(1)
subplot(2,1,1)
plot(t,rex,'b','LineWidth',2)
title('Parte Real x(t)','fontsize',16)
xlabel('Tiempo','fontsize',14)
ylabel('Re(x(t))','fontsize',14)
grid on
subplot(2,1,2)
plot(t,rez,'b',t,g,'r--')
legend('Datos Complejos','Gate')
%Parte Imaginaria
figure(2)
subplot(2,1,1)
plot(t,imx,'g','LineWidth',2)
title('Parte Imaginaria x(t)','fontsize',16)
xlabel('Tiempo','fontsize',14)
ylabel('Im(x(t))','fontsize',14)
grid on
subplot(2,1,2)
plot(t,imz,'g',t,g,'r--')
axis([-2 3 -1 1.2])
legend('Datos Complejos','Gate')
Con lo cual se obtienen las grficas:
Potencia instantanea:
syms t
x=(1+exp(-1i*3*t))*(heaviside(t+1)-heaviside(t-2));
Pi=abs(x)^2;
Potencia promedio: la potencia promedio es 0 como se ver al calcular la energa de la seal dada.
c) La energa
syms t
x=(1+exp(-1i*3*t))*(heaviside(t+1)-heaviside(t-2));
Pi=abs(x)^2;
%c)Energia
E=int(Pi,t,-inf,inf);
format long
eval(E)
ans =
5.907803006573961
P4) Suponga que mide la altura h del crecimiento de un cultivo. La altura es una funcin del tiempo.
Suponga que se mide la altura una vez al dia y se obtienen los siguientes datos:
t(dias) 1 2 3 4 5
h(cm) 1 1.6 3 6.2 12.8
c1 =
2.819999999999999 -3.539999999999997
c2 =
b) Dibuje los datos como puntos de muestra y la function h como recta continua
plot(t,h,'s',t,y1,t,y2)
legend('Datos','Ajuste Lineal','Ajuste Cuadratico','Location','NorthEastOutside')
title('Datos y Ajustes','fontsize',16)
xlabel('t(dias)','fontsize',14);
ylabel('h(cm)','fontsize',14);
grid on;
Datos y Ajustes
14
Datos
Ajuste Lineal
Ajuste Cuadratico
12
10
8
h(cm)
-2
1 1.5 2 2.5 3 3.5 4 4.5 5
t(dias)
( p( x ) y )
m 2
I i 1 i
( y y)
m 2
i 1 i
I1 =
0.847731536755926
I2 =
0.992738968348726
w w
40 log w 5 20 log w 40
| H1 |dB 5 | H 2 |dB 40
w5 w 40
0 0
w w
20 log w 200 20 log w 5000
| H 3 |dB 200 | H 4 |dB 5000
w 200 w 5000
0 0
a) Dibujar por separado las funciones mencionadas en el rango de frecuencias f E [0.1, 10000]Hz, con el
eje de frecuencias logartmica.
close all;clc;clear;
f=linspace(0.1,10000,100001);
w=2*pi*f;
%a)Graficas H1,H2,H3,H4
%Grafica H1
figure(1)
subplot(2,2,1)
H1=40*log10(w/5).*(5<w);
semilogx(w,H1,'b','LineWidth',3)
title('|H1|db=40log(w/5)','fontsize',16)
xlabel('w(rad/s)','fontsize',14)
ylabel('|H1|db','fontsize',14)
legend('|H1|db,w>5')
grid on
%Grafica H2
subplot(2,2,2)
H2=-20*log10(w/40).*(w>40);
semilogx(w,H2,'g','LineWidth',3)
title('|H2|db=-20log(w/40)','fontsize',16)
xlabel('w(rad/s)','fontsize',14)
ylabel('|H2|db','fontsize',14)
legend('|H2|db,w>40')
grid on
%Grafica H3
subplot(2,2,3)
H3=-20*log10(w/200).*(200<w);
semilogx(w,H3,'r','LineWidth',3)
title('|H3|db=-20log(w/200)','fontsize',16)
xlabel('w(rad/s)','fontsize',14)
ylabel('|H3|db','fontsize',14)
legend('|H3|db,w>200')
grid on
%Grafica H4
subplot(2,2,4)
H4=-20*log10(w/5000).*(5000<w);
semilogx(w,H4,'y','LineWidth',3)
title('|H4|db=-20log(w/5000)','fontsize',16)
xlabel('w(rad/s)','fontsize',14)
ylabel('|H4|db','fontsize',14)
legend('|H4|db,w>5000')
grid on
Con lo cual se obtiene la siguiente grafica:
|H1|db=40log(w/5) |H2|db=-20log(w/40)
200 0
|H1|db,w>5 |H2|db,w>40
-10
150
-20
|H1|db
|H2|db
-30
100
-40
-50
50
-60
0 -70
-1 0 1 2 3 4 5 -1 0 1 2 3 4 5
10 10 10 10 10 10 10 10 10 10 10 10 10 10
w(rad/s) w(rad/s)
|H3|db=-20log(w/200) |H4|db=-20log(w/5000)
0 0
|H3|db,w>200 |H4|db,w>5000
-10 -5
|H3|db
|H4|db
-20 -10
-30 -15
-40 -20
-50 -25
-1 0 1 2 3 4 5 -1 0 1 2 3 4 5
10 10 10 10 10 10 10 10 10 10 10 10 10 10
w(rad/s) w(rad/s)
b) Dibujar
| H 5 |dB | H1 |dB | H 2 |dB ; | H 6 |dB | H1 |dB | H 2 |dB | H 3 |dB ; | H 7 |dB | H1 |dB | H 2 |dB | H 3 |dB | H 4 |dB ;
Obtenga los valores de Magnitud en los codos de forma analtica para |H7|dB.
%b)Graficas H5,H6,H7
figure(2)
%Grafica H5
subplot(2,2,1)
H5=H1+H2;
semilogx(w,H5,'b','LineWidth',3)
title('|H5|db=|H1|db+|H2|db','fontsize',16)
xlabel('w(rad/s)','fontsize',14)
ylabel('|H5|db','fontsize',14)
legend('|H5|db')
grid on
%Grafica H6
subplot(2,2,2)
H6=H1+H2+H3;
semilogx(w,H6,'g','LineWidth',3)
title('|H6|db=|H1|db+|H2|db+|H3|db','fontsize',16)
xlabel('w(rad/s)','fontsize',14)
ylabel('|H6|db','fontsize',14)
legend('|H6|db')
grid on
%Grafica H7
subplot(2,2,[3 4])
H7=H1+H2+H3+H4;
semilogx(w,H7,'r','LineWidth',3)
title('|H7|db=|H1|db+|H2|db+|H3|db+|H4|db','fontsize',16)
xlabel('w(rad/s)','fontsize',14)
ylabel('|H7|db','fontsize',14)
legend('|H7|db');grid on
Con lo cual se obtienen las graficas de H5, H6 y H7.
|H5|db=|H1|db+|H2|db |H6|db=|H1|db+|H2|db+|H3|db
120 60
|H5|db |H6|db
100 50
80 40
|H5|db
|H6|db
60 30
40 20
20 10
0 0
-1 0 1 2 3 4 5 -1 0 1 2 3 4 5
10 10 10 10 10 10 10 10 10 10 10 10 10 10
w(rad/s) w(rad/s)
|H7|db=|H1|db+|H2|db+|H3|db+|H4|db
60
|H7|db
50
40
|H7|db
30
20
10
0
-1 0 1 2 3 4 5
10 10 10 10 10 10 10
w(rad/s)
Obtenga los valores de magnitud en los codos para |H7|db de forma analtica.
|H(w)db|=36.12359 + 20log(w/40)
Si: w=200 |H(w)db|=36.12359 + 20log(200/40)= 50.10299
Los clculos realizados analticamente se verifican con las grficas realizadas mediante MATLAB
como se puede apreciar en los cursores de H7 lo cual muestra su utilidad al realizar graficas
tediosas.
Al utilizar un eje logartmico, se debe tener en cuenta que el numero de puntos ha tomarse sea
mayor respecto a un eje lineal, ya que se puede obtener una grafica diferente a la esperada.
P6) Se tiene una red lineal e invariante en el tiempo que cuando se alimenta con la funcin x(t)=sgn(t) da
como respuesta la seal y(t) mostrada en la figura.
Se puede verificar grficamente que v(t) x(t) x(t 3) , sea z(t) la respuesta del sistema a la entrada
v(t). De la convolucin sabemos que:
subplot(1,2,1)
y0=(-t-2).*(t>-2 & t<-1)+(-t+2).*(t>1 & t<2); % y(t)
w=t-3; %Desplazamiento y(t-3)
y3=(-w-2).*(w>-2 & w<-1)+(-w+2).*(w>1 & w<2); % y(t-3)
plot(t,y0,'b',t,y3,'r--')
title('y(t) & y(t-3)','fontsize',16)
xlabel('Tiempo(ms)','fontsize',14)
legend('y(t)','y(t-3)')
axis([-3 6 -1.2 1.2])
grid on
subplot(1,2,2)
ytot=y0-y3;
plot(t,ytot,'g','LineWidth',2)
title('y(t)- y(t-3)','fontsize',16)
xlabel('Tiempo(ms)','fontsize',14)
legend('y(t)-y(t-3)')
axis([-3 6 -1.2 1.2])
grid on
y(t) & y(t-3) y(t)- y(t-3)
y(t) y(t)-y(t-3)
1 y(t-3) 1
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0 0
-0.2 -0.2
-0.4 -0.4
-0.6 -0.6
-0.8 -0.8
-1 -1
-3 -2 -1 0 1 2 3 4 5 6 -3 -2 -1 0 1 2 3 4 5 6
Tiempo(ms) Tiempo(ms)