Professional Documents
Culture Documents
1. Transformada de Fourier:
x[n] = cos(0.25pin) + cos(0.5pin)+ cos(0.52pin).
N=16
n = 0:15;
xn = cos(0.25*pi*n)+cos(0.5*pi*n)
+cos(0.52*pi*n);
L=length(xn);
XN=fft(xn,L);
j= fftshift(XN);
f=-1/2:1/L:1/2-1/L;
plot(f,abs(j))
xlabel(' FRECUENCIA Hz');
ylabel('AMPLITUD ');
grid on;
title(' ESPECTRO suma de seales');
N=32
n = 0:31;
xn = cos(0.25*pi*n)+cos(0.5*pi*n)
+cos(0.52*pi*n);
L=length(xn);
plot(n,xn)
XN=fft(xn,L);
f=-1/2:1/L:1/2-1/L;
plot(f,abs(XN))
xlabel(' FRECUENCIA Hz');
ylabel('AMPLITUD ');
grid on;
title(' ESPECTRO suma de seales');
N=64
n = 0:63;
n = 0:63;
xn = cos(0.25*pi*n)+cos(0.5*pi*n)
+cos(0.52*pi*n);
L=length(xn);
XN=fft(xn,L);
j= fftshift(XN);
f=-1/2:1/L:1/2-1/L;
plot(f,abs(j))
xlabel(' FRECUENCIA Hz');
ylabel('AMPLITUD ');
grid on;
title(' ESPECTRO suma de seales');
N=128
n = 0:127;
xn = cos(0.25*pi*n)+cos(0.5*pi*n)
+cos(0.52*pi*n);
L=length(xn);
XN=fft(xn,L);
j= fftshift(XN);
f=-1/2:1/L:1/2-1/L;
plot(f,abs(j))
xlabel(' FRECUENCIA Hz');
ylabel('AMPLITUD ');
grid on;
title(' ESPECTRO suma de seales');
N=256
n = 0:255;
xn = cos(0.25*pi*n)+cos(0.5*pi*n)
+cos(0.52*pi*n);
L=length(xn);
XN=fft(xn,L);
j= fftshift(XN);
f=-1/2:1/L:1/2-1/L;
plot(f,abs(j))
xlabel(' FRECUENCIA Hz');
ylabel('AMPLITUD ');
grid on;
title(' ESPECTRO suma de seales');
N=512
n = 0:511;
xn = cos(0.25*pi*n)+cos(0.5*pi*n)
+cos(0.52*pi*n);
L=length(xn);
XN=fft(xn,L);
j= fftshift(XN);
f=-1/2:1/L:1/2-1/L;
plot(f,abs(j))
xlabel(' FRECUENCIA Hz');
ylabel('AMPLITUD ');
grid on;
title(' ESPECTRO suma de seales');
frecuencias de las suma de los cosenos , si aumentamos el numero de muestras, por eso
desde 128 se logra una mejor resolucin.
c= 100;
1.6. Qu frecuencia de muestreo debe usarse? Justifique su respuesta
La teora de muestreo Nyquist dice que se debe usar 2 o mas veces la frecuencia
fundamental. Para que la seal sea muestreada correctamente.
xt = 0.0472*cos(2*pi*(200)*t + 1.5077) +
0.1362*cos(2*pi*(400)*t + 1.8769) +
0.4884 *cos(2*pi*(500)*t- 0.1852)
+0.2942*cos(2*pi*(1600)*t -1.4488) +
0.1223*cos(2*pi*(1700)*t);
A= [200 400 500 1600 1700 ]
c = A(1);
for k = 2:length(A)
c = gcd(c,A(k));
end
Fs= c*100 ; % utilizando nyquist decimos
quela frecuencia de muestreo es 2 o mas
veces la frecuencia fundamental de la
senal
L=length(xt);
f=-1/2:1/L:1/2-1/L;
f=2*pi*f;
XN=fft(xt,L);
subplot(2,1,1)
stem(f,2*pi*abs(XN)))
xlabel(' FRECUENCIA W');
ylabel('AMPLITUD ');
grid on;
subplot(2,1,2)
plot(f,2*pi*phase(XN))
xlabel(' W');
ylabel('AMPLITUD ');
grid on;
2. Diseo de Filtros:
2.1. Disee los filtros necesarios (pasabajo) utilizando fdatool:
ecg=load('necg.txt');
Fs= 360;
Sfiltrada= sosfilt(SOS,ecg);
[m,n]=size(ecg);
b = fft(ecg,m);
f_esp= Fs/m;
fNy=Fs/2;
f_ini=-fNy;
f_fin=fNy-f_esp;
f=f_ini:f_esp:f_fin;
plot(f,2*fftshift(abs(b)));
[m,n]=size(ecg);
b = fft(ecg,m);
f_esp= Fs/m;
fNy=Fs/2;
f_ini=-fNy;
f_fin=fNy-f_esp;
f=f_ini:f_esp:f_fin;
subplot
subplot (3,2,[1 ])
plot(t,ecg);
axis([0 2.9 -600 900]);
xlabel(' TIMEPO s');
ylabel('AMPLITUD ');
grid on;
title('ECG');
subplot (3,2,2)
Sindeseado= sosfilt(SOS1,ecg);
g=fft(Sindeseado,m);
plot(f,fftshift(0.5*abs(g)), 'r');
xlabel(' FRECUENCIA Hz');
ylabel('AMPLITUD ');
title(' ESPECTRO ECG INDESEADO');
grid on;
subplot (3,2,3)
plot(f,fftshift(abs(b)), 'g');
xlabel(' FRECUENCIA Hz');
ylabel('AMPLITUD ');
grid on;
title(' ESPECTRO ECG SIN FILTRO');
subplot (3,2,4)
Sfiltrada= sosfilt(SOS,ecg);
plot(t,Sfiltrada);
xlim([0 3]);
xlabel(' TIMEPO s');
ylabel('AMPLITUD ');
grid on;
title(' ECG dominio tiempo FLITRADO 40 Hz');
subplot (3,2,[5 6 ])
c = fft(Sfiltrada,m);
plot(f,fftshift(abs(c)));
xlabel(' FRECUENCIA Hz');
ylabel('AMPLITUD ');
title(' ESPECTRO ECG FLITRADO 40 Hz');
Ulitice un filtro butterworth del mismo orden anterior (17) pero esta vez programado
sobre la
lnea de comando: [b a]=butter(17,wn) con wn=40/360=40/(fs/2), filtre la seal ecg con
la funcin filter
y filtfilt, guarde ambas seales.
f_esp= Fs/m;
fNy=Fs/2;
f_ini=-fNy;
f_fin=fNy-f_esp;
f=f_ini:f_esp:f_fin;
subplot(4,2,1);
plot(t,ecg);
xlabel(' tiempo s');
ylabel('AMPLITUD ');
grid on;
title('Seal en tiempo de ECG')
subplot(4,2,2);
plot(f,fftshift(abs(x)));
title('espectro de ECG')
title('espectro de FILTFILT')
xlabel(' frecuencia HZ');
ylabel('AMPLITUD ');
grid on;
subplot(4,2,3);
plot(t,filtro3);
title('Seal en tiempo de SOSFILTER')
xlabel(' tiempo s');
ylabel('AMPLITUD ');
grid on;
subplot(4,2,4);
plot(f,fftshift(abs(yfiltro3)));
title('espectro de SOSFILTER')
title('espectro de FILTFILT')
xlabel(' frecuencia HZ');
ylabel('AMPLITUD ');
grid on;
subplot(4,2,5);
plot(t,filtro1);
title('Seal en tiempo de FILTER')
xlabel(' tiempo s');
ylabel('AMPLITUD ');
grid on;
subplot(4,2,6);
plot(f,fftshift(abs(yfiltro1)));
title('espectro de FILTFILT')
xlabel(' frecuencia HZ');
ylabel('AMPLITUD ');
grid on;
subplot(4,2,7);
plot(t,filtro2);
title('Seal en tiempo de FILTFILT')
xlabel(' tiempo s');
ylabel('AMPLITUD ');
grid on;
subplot(4,2,8);
plot(f,fftshift(abs(yfiltro2)));
title('espectro de FILTFILT')
xlabel(' frecuencia HZ');
ylabel('AMPLITUD ');
grid on;
Observando los ecgs en tiempo, que ventajas tiene filtfilt sobre filter?.
filtfilt
adems posee ventajas debido a que tiene Distorsin de fase cero ,Una funcin de
transferencia de filtro, que es igual a la magnitud cuadrtica de la funcin de
transferencia de filtro original y Una orden de filtro que es el doble del orden del filtro
especificado por b y a
y = filter( b , a , x ) filtra los datos de entrada x utilizando una funcin de
transferencia racional definida por el numerador y denominador coeficientes b y a .