You are on page 1of 2

clear all

close all
clc

f1=30;
f2=150;
f3=200;
f4=400;
fs=10000;

t=0:(1/fs):0.05-(1/fs);
x1= 2*sin(2*pi*f1*t);
x2= 5*sin(2*pi*f2*t);
x3= 1.5*sin(2*pi*f3*t);
x4= 3.7*sin(2*pi*f4*t);

x=x1+x4;

plot(t,x)
grid

N=length(x)
ts=1/fs
tmax=(N-1)*ts
t1=0:ts:tmax
f=-fs/2:fs/(N-1):fs/2;
z=fftshift(fft(x))
figure
stem(f,abs(z))
grid

Fc=200;
Wn=Fc/(fs/2);
N=5;

[num,den]=butter(N,Wn,'high');

%[num,den]=cheby1(N,Wn,0.0000006, 'high');
%[num,den]=cheby2(N,Wn,0.006,'high');
%[num,den]=ellip(N,Wn,0.6,0.56,'high');

figure
freqz(num,den,1)

yout1=filter(num,den,x);

b=fir1(N,Wn,'high');
figure
freqz(b,1)

yout2=filter(b,1,x)

figure
subplot(5,1,1)
plot(t,x1)
xlabel('tiempo en segundo');
ylabel('X1 a 20 Hz')
grid
subplot(5,1,2)
plot(t,x4)
xlabel('tiempo en segundos');
ylabel('X4 a 400 Hz')
grid

subplot(5,1,3)
plot(t,x)
xlabel('tiempo de segundos');
ylabel('suma de las señales')
grid

subplot(5,1,4)
plot(t,yout1)
xlabel('tiempo de segundos');
ylabel('señales filtrada IIR')
grid

subplot(5,1,5)
plot(t,yout2)
xlabel('tiempo de segundos');
ylabel('señales filtrada FIR')
grid

You might also like