Skip to main content
added 2 characters in body
Source Link
Fat32
  • 28.4k
  • 3
  • 24
  • 51

I'm trying implement aan IIR filter.I I know the IIR filter come from that equation: equation

and i found that for high pass filter the coefficients are:

coe

where fc = cut freq.

here my matlab code:

fs = 1000;
fc=0.3;
r=exp(-2*pi*fc);
a = [(1+r)/2 -(1+r)/2];
b= [1 -r];
n = 0:1/(fs):20;
n1 = 1024;
x1 = cos(0.3*2*pi.*n);
x2 = cos(0.8*2*pi.*n);
%plot(n,x1);
%hold on
%plot(n,x2);
%hold on
%plot(n,x1+x2);
%aux = fft((x1+x2),n1);
%aux = aux(1:n1/2);
%f = (0:n1/2-1)*(fs/n1);
%length(f)
%legend('x1[n]','x2[n]','x1+x2')
%plot(f,abs(aux));
%hold on

y = filter([0.5759 -0.5759],[1 -0.1518] , x1+x2);
plot(n,y,'r-',n,x2,'b--',n,x1,'g-.');
grid
%axis([0 100 -1.2 4]);
ylabel('Amplitude');
xlabel('Time index n');
legend('y[n]','x2[n]','x1[n]')

the commented parts are from FFT part of program and it's working well but the filter function isn't working. Help me plz and sorry about my english.

I'm trying implement a IIR filter.I know the IIR filter come from that equation: equation

and i found that for high pass filter the coefficients are:

coe

where fc = cut freq.

here my matlab code:

fs = 1000;
fc=0.3;
r=exp(-2*pi*fc);
a = [(1+r)/2 -(1+r)/2];
b= [1 -r];
n = 0:1/(fs):20;
n1 = 1024;
x1 = cos(0.3*2*pi.*n);
x2 = cos(0.8*2*pi.*n);
%plot(n,x1);
%hold on
%plot(n,x2);
%hold on
%plot(n,x1+x2);
%aux = fft((x1+x2),n1);
%aux = aux(1:n1/2);
%f = (0:n1/2-1)*(fs/n1);
%length(f)
%legend('x1[n]','x2[n]','x1+x2')
%plot(f,abs(aux));
%hold on

y = filter([0.5759 -0.5759],[1 -0.1518] , x1+x2);
plot(n,y,'r-',n,x2,'b--',n,x1,'g-.');
grid
%axis([0 100 -1.2 4]);
ylabel('Amplitude');
xlabel('Time index n');
legend('y[n]','x2[n]','x1[n]')

the commented parts are from FFT part of program and it's working well but the filter function isn't working. Help me plz and sorry about my english.

I'm trying implement an IIR filter. I know the IIR filter come from that equation: equation

and i found that for high pass filter the coefficients are:

coe

where fc = cut freq.

here my matlab code:

fs = 1000;
fc=0.3;
r=exp(-2*pi*fc);
a = [(1+r)/2 -(1+r)/2];
b= [1 -r];
n = 0:1/(fs):20;
n1 = 1024;
x1 = cos(0.3*2*pi.*n);
x2 = cos(0.8*2*pi.*n);
%plot(n,x1);
%hold on
%plot(n,x2);
%hold on
%plot(n,x1+x2);
%aux = fft((x1+x2),n1);
%aux = aux(1:n1/2);
%f = (0:n1/2-1)*(fs/n1);
%length(f)
%legend('x1[n]','x2[n]','x1+x2')
%plot(f,abs(aux));
%hold on

y = filter([0.5759 -0.5759],[1 -0.1518] , x1+x2);
plot(n,y,'r-',n,x2,'b--',n,x1,'g-.');
grid
%axis([0 100 -1.2 4]);
ylabel('Amplitude');
xlabel('Time index n');
legend('y[n]','x2[n]','x1[n]')

the commented parts are from FFT part of program and it's working well but the filter function isn't working. Help me plz and sorry about my english.

deleted 1 character in body
Source Link
Fat32
  • 28.4k
  • 3
  • 24
  • 51

I'm trying implement a IIR filter.I know the IIR filter come from that equation: equation

and i found that for high pass filter the coefficients are:

coe

where fc = cut freq.

here my matlab code:

fs = 1000;
fc=0.3;
r=exp(-2*pi*fc);
a = [(1+r)/2 -(1+r)/2];
b= [1 -r];
n = 0:1/(fs):20;
n1 = 1024;
x1 = cos(0.3*2*pi.*n);
x2 = cos(0.8*2*pi.*n);
%plot(n,x1);
%hold on
%plot(n,x2);
%hold on
%plot(n,x1+x2);
%aux = fft((x1+x2),n1);
%aux = aux(1:n1/2);
%f = (0:n1/2-1)*(fs/n1);
%length(f)
%legend('x1[n]','x2[n]','x1+x2')
%plot(f,abs(aux));
%hold on

y = filter([0.5759 -0.5759],[1 -0.1518] , x1+x2);
plot(n,y,'r-',n,x2,'b--',n,x1,'g-.');
grid
%axis([0 100 -1.2 4]);
ylabel('Amplitude');
xlabel('Time index n');
legend('y[n]','x2[n]','x1[n]')

the commented parts are from FFT part of program and it's working well but the filter function isn't working. Help me plz and sorry about my english.

I'm trying implement a IIR filter.I know the IIR filter come from that equation: equation

and i found that for high pass filter the coefficients are:

coe

where fc = cut freq.

here my matlab code:

fs = 1000;
fc=0.3;
r=exp(-2*pi*fc);
a = [(1+r)/2 -(1+r)/2];
b= [1 -r];
n = 0:1/(fs):20;
n1 = 1024;
x1 = cos(0.3*2*pi.*n);
x2 = cos(0.8*2*pi.*n);
%plot(n,x1);
%hold on
%plot(n,x2);
%hold on
%plot(n,x1+x2);
%aux = fft((x1+x2),n1);
%aux = aux(1:n1/2);
%f = (0:n1/2-1)*(fs/n1);
%length(f)
%legend('x1[n]','x2[n]','x1+x2')
%plot(f,abs(aux));
%hold on

y = filter([0.5759 -0.5759],[1 -0.1518] , x1+x2);
plot(n,y,'r-',n,x2,'b--',n,x1,'g-.');
grid
%axis([0 100 -1.2 4]);
ylabel('Amplitude');
xlabel('Time index n');
legend('y[n]','x2[n]','x1[n]')

the commented parts are from FFT part of program and it's working well but the filter function isn't working. Help me plz and sorry about my english.

I'm trying implement a IIR filter.I know the IIR filter come from that equation: equation

and i found that for high pass filter the coefficients are:

coe

where fc = cut freq.

here my matlab code:

fs = 1000;
fc=0.3;
r=exp(-2*pi*fc);
a = [(1+r)/2 -(1+r)/2];
b= [1 -r];
n = 0:1/(fs):20;
n1 = 1024;
x1 = cos(0.3*2*pi.*n);
x2 = cos(0.8*2*pi.*n);
%plot(n,x1);
%hold on
%plot(n,x2);
%hold on
%plot(n,x1+x2);
%aux = fft((x1+x2),n1);
%aux = aux(1:n1/2);
%f = (0:n1/2-1)*(fs/n1);
%length(f)
%legend('x1[n]','x2[n]','x1+x2')
%plot(f,abs(aux));
%hold on

y = filter([0.5759 -0.5759],[1 -0.1518] , x1+x2);
plot(n,y,'r-',n,x2,'b--',n,x1,'g-.');
grid
%axis([0 100 -1.2 4]);
ylabel('Amplitude');
xlabel('Time index n');
legend('y[n]','x2[n]','x1[n]')

the commented parts are from FFT part of program and it's working well but the filter function isn't working. Help me plz and sorry about my english.

Source Link

IIR high pass filter

I'm trying implement a IIR filter.I know the IIR filter come from that equation: equation

and i found that for high pass filter the coefficients are:

coe

where fc = cut freq.

here my matlab code:

fs = 1000;
fc=0.3;
r=exp(-2*pi*fc);
a = [(1+r)/2 -(1+r)/2];
b= [1 -r];
n = 0:1/(fs):20;
n1 = 1024;
x1 = cos(0.3*2*pi.*n);
x2 = cos(0.8*2*pi.*n);
%plot(n,x1);
%hold on
%plot(n,x2);
%hold on
%plot(n,x1+x2);
%aux = fft((x1+x2),n1);
%aux = aux(1:n1/2);
%f = (0:n1/2-1)*(fs/n1);
%length(f)
%legend('x1[n]','x2[n]','x1+x2')
%plot(f,abs(aux));
%hold on

y = filter([0.5759 -0.5759],[1 -0.1518] , x1+x2);
plot(n,y,'r-',n,x2,'b--',n,x1,'g-.');
grid
%axis([0 100 -1.2 4]);
ylabel('Amplitude');
xlabel('Time index n');
legend('y[n]','x2[n]','x1[n]')

the commented parts are from FFT part of program and it's working well but the filter function isn't working. Help me plz and sorry about my english.