20
B/Etude pratique Filre RIF : Programme avec matlab : Filtre passe bas : clear all; close all; fe=1000; f0=80; fc=input('tapez la frequence de coupure fc='); N=256; M=512; %calcule de la reponse impusionelle h(k) L=129;%nobre des echantiollons de h(k) l=(-(L-1)/2:(L-1)/2); h=((2*fc)/fe)*sinc(2*fc*l/fe); for k=1:N x1(k)=cos(2*pi*f0*k/fe); x2(k)=square(2*pi*f0*k/fe); x3(k)=sawtooth(2*pi*f0*k/fe); end; y1=filter(h,1,x1); y2=filter(h,1,x2); y3=filter(h,1,x3); %transformer de fourier de reponce impulsionnelle fh=fftshift(abs(fft(h,M))),title('T F de reponce impulsionnelle'); figure(1); subplot(321),plot(x1),title('x1'); subplot(322),plot(y1),title('y1'); subplot(323),plot(x2),title('x2'); subplot(324),plot(y2),title('y2'); subplot(325),plot(x3),title('x3'); subplot(326),plot(y3),title('y3'); %transformer de fourier des signaux et des filtres fx1=fftshift(abs(fft(x1,M))),title('T F de x1'); fx2=fftshift(abs(fft(x2,M))),title('T F de x2'); fx3=fftshift(abs(fft(x3,M))),title('T F de x3'); fy1=fftshift(abs(fft(y1,M))),title('T F de y1'); fy2=fftshift(abs(fft(y2,M))),title('T F de y2'); fy3=fftshift(abs(fft(y3,M))),title('T F de y3'); figure(2); subplot(531),plot(x1),title('x1'); subplot(532),plot(x2),title('x2'); subplot(533),plot(x3),title('x3'); subplot(534),plot(fx1),title('fx1'); subplot(535),plot(fx2),title('fx2'); subplot(536),plot(fx3),title('fx3');

tp traitement signal filtre RIF

Embed Size (px)

DESCRIPTION

FILTRE RIF

Citation preview

B/Etude pratique Filre RIF:Programme avec matlab:Filtre passe bas:

clear all;close all;fe=1000;f0=80;fc=input('tapez la frequence de coupure fc=');N=256;M=512;%calcule de la reponse impusionelle h(k)L=129;%nobre des echantiollons de h(k)l=(-(L-1)/2:(L-1)/2);h=((2*fc)/fe)*sinc(2*fc*l/fe);for k=1:N x1(k)=cos(2*pi*f0*k/fe); x2(k)=square(2*pi*f0*k/fe); x3(k)=sawtooth(2*pi*f0*k/fe);end;y1=filter(h,1,x1);y2=filter(h,1,x2);y3=filter(h,1,x3);%transformer de fourier de reponce impulsionnellefh=fftshift(abs(fft(h,M))),title('T F de reponce impulsionnelle');figure(1);subplot(321),plot(x1),title('x1');subplot(322),plot(y1),title('y1');subplot(323),plot(x2),title('x2');subplot(324),plot(y2),title('y2');subplot(325),plot(x3),title('x3');subplot(326),plot(y3),title('y3');%transformer de fourier des signaux et des filtresfx1=fftshift(abs(fft(x1,M))),title('T F de x1');fx2=fftshift(abs(fft(x2,M))),title('T F de x2');fx3=fftshift(abs(fft(x3,M))),title('T F de x3');fy1=fftshift(abs(fft(y1,M))),title('T F de y1');fy2=fftshift(abs(fft(y2,M))),title('T F de y2');fy3=fftshift(abs(fft(y3,M))),title('T F de y3');figure(2);subplot(531),plot(x1),title('x1');subplot(532),plot(x2),title('x2');subplot(533),plot(x3),title('x3');subplot(534),plot(fx1),title('fx1');subplot(535),plot(fx2),title('fx2');subplot(536),plot(fx3),title('fx3');subplot(537),plot(fh),title('T F de reponce impulsionnelle');subplot(538),plot(fh),title('T F de reponce impulsionnelle');subplot(539),plot(fh),title('T F de reponce impulsionnelle');subplot(5,3,10),plot(y1),title('y1');subplot(5,3,11),plot(y2),title('y2');subplot(5,3,12),plot(y3),title('y3');subplot(5,3,13),plot(fy1),title('fy1');subplot(5,3,14),plot(fy2),title('fy2');subplot(5,3,15),plot(fy3),title('fy3'); %fc=400

La reprsentation graphique des signaux:

Filtre passe haut:Le programme:clear all;close all;fe=2000;f0=80;fc=input('tapez la frequence de coupure fc=');fc2=input('tapez la frequence de coupure fc2=');N=256;M=512;%calcule de la reponse impusionelle h(k)L=129;%nobre des echantiollons de h(k)l=(-(L-1)/2:(L-1)/2);g=zeros(1,L); %g=peigne de diract passe tout g(65)=1; %decalage jusqu'a 65 h=((2*fc)/fe)*sinc(2*fc*l/fe); %filter bas frequence de fc =100h2=((2*fc2)/fe)*sinc(2*fc2*l/fe);%filter bas frequence de fc2 =300h3=h2-h % filtre pass band h4=g-h %filtre haut frequencefor k=1:N x1(k)=cos(2*pi*f0*k/fe); x2(k)=square(2*pi*f0*k/fe); x3(k)=sawtooth(2*pi*f0*k/fe);end;y1=filter(h4,1,x1);y2=filter(h4,1,x2);y3=filter(h4,1,x3);%transformer de fourier de reponce impulsionnellefh4=fftshift(abs(fft(h4,M))),title('T F de reponce impulsionnelle');figure(1);subplot(321),plot(x1),title('x1');subplot(322),plot(y1),title('y1');subplot(323),plot(x2),title('x2');subplot(324),plot(y2),title('y2');subplot(325),plot(x3),title('x3');subplot(326),plot(y3),title('y3');%transformer de fourier des signaux et des filtresfx1=fftshift(abs(fft(x1,M))),title('T F de x1');fx2=fftshift(abs(fft(x2,M))),title('T F de x2');fx3=fftshift(abs(fft(x3,M))),title('T F de x3');fy1=fftshift(abs(fft(y1,M))),title('T F de y1');fy2=fftshift(abs(fft(y2,M))),title('T F de y2');fy3=fftshift(abs(fft(y3,M))),title('T F de y3');figure(2);subplot(531),plot(x1),title('x1');subplot(532),plot(x2),title('x2');subplot(533),plot(x3),title('x3');subplot(534),plot(fx1),title('fx1');subplot(535),plot(fx2),title('fx2');subplot(536),plot(fx3),title('fx3');subplot(537),plot(fh4),title('T F de reponce impulsionnelle');subplot(538),plot(fh4),title('T F de reponce impulsionnelle');subplot(539),plot(fh4),title('T F de reponce impulsionnelle');subplot(5,3,10),plot(y1),title('y1');subplot(5,3,11),plot(y2),title('y2');subplot(5,3,12),plot(y3),title('y3');subplot(5,3,13),plot(fy1),title('fy1');subplot(5,3,14),plot(fy2),title('fy2');subplot(5,3,15),plot(fy3),title('fy3');

reprsentation graphique:

filtre passe bande:le programme:clear all;close all;fe=1000;f0=80;fc=input('tapez la frequence de coupure fc=');fc2=input('tapez la frequence de coupure fc2=');N=256;M=512;%calcule de la reponse impusionelle h(k)L=129;%nobre des echantiollons de h(k)l=(-(L-1)/2:(L-1)/2);h=((2*fc)/fe)*sinc(2*fc*l/fe);h2=((2*fc2)/fe)*sinc(2*fc2*l/fe);h3=h2-hfor k=1:N x1(k)=cos(2*pi*f0*k/fe); x2(k)=square(2*pi*f0*k/fe); x3(k)=sawtooth(2*pi*f0*k/fe);end;y1=filter(h3,1,x1);y2=filter(h3,1,x2);y3=filter(h3,1,x3);%transformer de fourier de reponce impulsionnellefh3=fftshift(abs(fft(h3,M))),title('T F de reponce impulsionnelle');figure(1);subplot(321),plot(x1),title('x1');subplot(322),plot(y1),title('y1');subplot(323),plot(x2),title('x2');subplot(324),plot(y2),title('y2');subplot(325),plot(x3),title('x3');subplot(326),plot(y3),title('y3');%transformer de fourier des signaux et des filtresfx1=fftshift(abs(fft(x1,M))),title('T F de x1');fx2=fftshift(abs(fft(x2,M))),title('T F de x2');fx3=fftshift(abs(fft(x3,M))),title('T F de x3');fy1=fftshift(abs(fft(y1,M))),title('T F de y1');fy2=fftshift(abs(fft(y2,M))),title('T F de y2');fy3=fftshift(abs(fft(y3,M))),title('T F de y3');figure(2);subplot(531),plot(x1),title('x1');subplot(532),plot(x2),title('x2');subplot(533),plot(x3),title('x3');subplot(534),plot(fx1),title('fx1');subplot(535),plot(fx2),title('fx2');subplot(536),plot(fx3),title('fx3');subplot(537),plot(fh3),title('T F de reponce impulsionnelle');subplot(538),plot(fh3),title('T F de reponce impulsionnelle');subplot(539),plot(fh3),title('T F de reponce impulsionnelle');subplot(5,3,10),plot(y1),title('y1');subplot(5,3,11),plot(y2),title('y2');subplot(5,3,12),plot(y3),title('y3');subplot(5,3,13),plot(fy1),title('fy1');subplot(5,3,14),plot(fy2),title('fy2');subplot(5,3,15),plot(fy3),title('fy3'); %fc=400

reprsentation graphique:

Filtre coupe bande:Le programme:clear all;close all;fe=1000;f0=80;fc=input('tapez la frequence de coupure fc=');fc2=input('tapez la frequence de coupure fc2=');N=256;M=512;%calcule de la reponse impusionelle h(k)L=129;%nobre des echantiollons de h(k)l=(-(L-1)/2:(L-1)/2);g=zeros(1,L); %g=peigne de diract =tou pas g(65)=1; %decalage jusqu'a 65 h=((2*fc)/fe)*sinc(2*fc*l/fe); %filter bas frequence de fc =100h2=((2*fc2)/fe)*sinc(2*fc2*l/fe);%filter bas frequence de fc2 =300h3=h2-h % filtre pass band h4=g-h %filtre haut frequenceh5=g-h3 %filtre coupe bandfor k=1:N x1(k)=cos(2*pi*f0*k/fe); x2(k)=square(2*pi*f0*k/fe); x3(k)=sawtooth(2*pi*f0*k/fe);end;y1=filter(h5,1,x1);y2=filter(h5,1,x2);y3=filter(h5,1,x3);%transformer de fourier de reponce impulsionnellefh5=fftshift(abs(fft(h5,M))),title('T F de reponce impulsionnelle');figure(1);subplot(321),plot(x1),title('x1');subplot(322),plot(y1),title('y1');subplot(323),plot(x2),title('x2');subplot(324),plot(y2),title('y2');subplot(325),plot(x3),title('x3');subplot(326),plot(y3),title('y3');%transformer de fourier des signaux et des filtresfx1=fftshift(abs(fft(x1,M))),title('T F de x1');fx2=fftshift(abs(fft(x2,M))),title('T F de x2');fx3=fftshift(abs(fft(x3,M))),title('T F de x3');fy1=fftshift(abs(fft(y1,M))),title('T F de y1');fy2=fftshift(abs(fft(y2,M))),title('T F de y2');fy3=fftshift(abs(fft(y3,M))),title('T F de y3');figure(2);subplot(531),plot(x1),title('x1');subplot(532),plot(x2),title('x2');subplot(533),plot(x3),title('x3');subplot(534),plot(fx1),title('fx1');subplot(535),plot(fx2),title('fx2');subplot(536),plot(fx3),title('fx3');subplot(537),plot(fh5),title('T F de reponce impulsionnelle');subplot(538),plot(fh5),title('T F de reponce impulsionnelle');subplot(539),plot(fh5),title('T F de reponce impulsionnelle');subplot(5,3,10),plot(y1),title('y1');subplot(5,3,11),plot(y2),title('y2');subplot(5,3,12),plot(y3),title('y3');subplot(5,3,13),plot(fy1),title('fy1');subplot(5,3,14),plot(fy2),title('fy2');subplot(5,3,15),plot(fy3),title('fy3'); %fc=100 fc2=300

Reprsentation graphique:

Filre RII: filtre basse bas:le programme:

%tp5: filtrage RIF eT RII%Chiheb Chihabeddine%Guerroui Mohammed%h(k)=2*fc/fe*sinc(2*fck/fe)clear all;close all;fe=2000;f0=50; N=256;M=512;s=[-fe/2:fe/M:(fe/2)-1];s1=[1:fe/M:(fe/2)-1];fc1=input('tappez la frquence de coupure fc1=');% calcule de la frquence impultionelle h(t)L=129;% la longueure de h(t). le nombre d'echantillonsl=[(-L-1)/2:(L-1)/2];%hpb1=(2*fc1/fe)*sinc(2*fc1*l/fe);%hpb2=(2*fc2/fe)*sinc(2*fc2*l/fe);Wn1=2*fc1/fe;% frquence de couppure ,normalise 1 Wn=[Wn1 ];N1=8;[B,A] = BUTTER(N1,Wn);[H,W] = FREQZ(B,A,N,fe);fh=abs(H);%h=hpb2-hpb1;for k=1:N x1(k)=cos(2*pi*f0*k/fe); x2(k)=square(2*pi*f0*k/fe); x3(k)=sawtooth(2*pi*f0*k/fe);endy1=filter(B,A,x1);y2=filter(B,A,x2);y3=filter(B,A,x3);%transforme de fourier des signaux filtrsfy11=(abs(fft(y1,M)));fy1=fy11(1:M/2);fy22=(abs(fft(y2,M)));fy2=fy22(1:M/2);fy33=(abs(fft(y3,M)));fy3=fy33(1:M/2);%transforme de fourier de la rponse impulsionnelle%fh=fftshift(abs(fft(h,M)));%transforme de signaux d'entr fx11=(abs(fft(x1,M)));fx1=fx11(1:M/2);fx22=(abs(fft(x2,M)));fx2=fx22(1:M/2);fx33=(abs(fft(x3,M)));fx3=fx33(1:M/2); figure(1)subplot(531),plot(x1),title('x1');subplot(532),plot(x2),title('x2');subplot(533),plot(x3),title('x3');subplot(534),plot(s1,fx1),title('fx1');subplot(535),plot(s1,fx2),title('fx2');subplot(536),plot(s1,fx3),title('fx3');subplot(537),plot(s1,fh),title('fh');subplot(538),plot(s1,fh),title('fh');subplot(539),plot(s1,fh),title('fh');subplot(5,3,10),plot(y1),title('y1');subplot(5,3,11),plot(y2),title('y2');subplot(5,3,12),plot(y3),title('y3');subplot(5,3,13),plot(s1,fy1),title('fy1');subplot(5,3,14),plot(s1,fy2),title('fy2');subplot(5,3,15),plot(s1,fy3),title('fy3');

reprsentation graphique:

Filtre passe bande:Le programme:%tp5: filtrage RIF eT RII%Chiheb Chihabeddine%Guerroui Mohammedclear all;close all;fe=2000;f0=50;N=256;M=512;s=[-fe/2:fe/M:(fe/2)-1];s1=[1:fe/M:(fe/2)-1];fc1=input('tappez la frquence de coupure fc1=');fc2=input('tappez la frquence de coupure fc2=');% calcule de la frquence impultionelle h(t)L=129;% la longueure de h(t). le nombre d'echantillonsl=[(-L-1)/2:(L-1)/2];Wn1=2*fc1/fe;% frquence de couppure ,normalise 1Wn2=2*fc2/fe;%frquence de couppure ,normalise 2Wn=[Wn1 Wn2];N1=8;[B,A] = BUTTER(N1,Wn);[H,W] = FREQZ(B,A,N,fe);fh=abs(H);%h=hpb2-hpb1;for k=1:N x1(k)=cos(2*pi*f0*k/fe); x2(k)=square(2*pi*f0*k/fe); x3(k)=sawtooth(2*pi*f0*k/fe);endy1=filter(B,A,x1);y2=filter(B,A,x2);y3=filter(B,A,x3);%transforme de fourier des signaux filtrsfy11=(abs(fft(y1,M)));fy1=fy11(1:M/2);fy22=(abs(fft(y2,M)));fy2=fy22(1:M/2);fy33=(abs(fft(y3,M)));fy3=fy33(1:M/2);%transforme de fourier de la rponse impulsionnelle%fh=fftshift(abs(fft(h,M)));%transforme de signaux d'entr fx11=(abs(fft(x1,M)));fx1=fx11(1:M/2);fx22=(abs(fft(x2,M)));fx2=fx22(1:M/2);fx33=(abs(fft(x3,M)));fx3=fx33(1:M/2); figure(1)subplot(531),plot(x1),title('x1');subplot(532),plot(x2),title('x2');subplot(533),plot(x3),title('x3');subplot(534),plot(s1,fx1),title('fx1');subplot(535),plot(s1,fx2),title('fx2');subplot(536),plot(s1,fx3),title('fx3');subplot(537),plot(s1,fh),title('fh');subplot(538),plot(s1,fh),title('fh');subplot(539),plot(s1,fh),title('fh');subplot(5,3,10),plot(y1),title('y1');subplot(5,3,11),plot(y2),title('y2');subplot(5,3,12),plot(y3),title('y3');subplot(5,3,13),plot(s1,fy1),title('fy1');subplot(5,3,14),plot(s1,fy2),title('fy2');subplot(5,3,15),plot(s1,fy3),title('fy3');

Reprsentation graphique:

Passe haut: Le programme:

%tp5: filtrage RIF eT RII%Chiheb Chihabeddine%Guerroui Mohammedclear all;close all;fe=2000;f0=50; N=256;M=512;s=[-fe/2:fe/M:(fe/2)-1];s1=[1:fe/M:(fe/2)-1];fc1=input('tappez la frquence de coupure fc1=');% calcule de la frquence impultionelle h(t)L=129;% la longueure de h(t). le nombre d'echantillonsl=[(-L-1)/2:(L-1)/2];Wn1=2*fc1/fe;% frquence de couppure ,normalise 1Wn=[Wn1 ];N1=8;[B,A] = BUTTER(N1,Wn,'high');[H,W] = FREQZ(B,A,N,fe);fh=abs(H);%h=hpb2-hpb1;for k=1:N x1(k)=cos(2*pi*f0*k/fe); x2(k)=square(2*pi*f0*k/fe); x3(k)=sawtooth(2*pi*f0*k/fe);endy1=filter(B,A,x1);y2=filter(B,A,x2);y3=filter(B,A,x3);%transforme de fourier des signaux filtrsfy11=(abs(fft(y1,M)));fy1=fy11(1:M/2);fy22=(abs(fft(y2,M)));fy2=fy22(1:M/2);fy33=(abs(fft(y3,M)));fy3=fy33(1:M/2);%transforme de signaux d'entr fx11=(abs(fft(x1,M)));fx1=fx11(1:M/2);fx22=(abs(fft(x2,M)));fx2=fx22(1:M/2);fx33=(abs(fft(x3,M)));fx3=fx33(1:M/2); figure(1)subplot(531),plot(x1),title('x1');subplot(532),plot(x2),title('x2');subplot(533),plot(x3),title('x3');subplot(534),plot(s1,fx1),title('fx1');subplot(535),plot(s1,fx2),title('fx2');subplot(536),plot(s1,fx3),title('fx3');subplot(537),plot(s1,fh),title('fh');subplot(538),plot(s1,fh),title('fh');subplot(539),plot(s1,fh),title('fh');subplot(5,3,10),plot(y1),title('y1');subplot(5,3,11),plot(y2),title('y2');subplot(5,3,12),plot(y3),title('y3');subplot(5,3,13),plot(s1,fy1),title('fy1');subplot(5,3,14),plot(s1,fy2),title('fy2');subplot(5,3,15),plot(s1,fy3),title('fy3');

reprsentation graphique:

Filtre coupe bande:Le programme: %tp5: filtrage RIF eT RII%Chiheb Chihabeddine%Guerroui Mohammed%h(k)=2*fc/fe*sinc(2*fck/fe)clear all;close all;fe=2000;f0=50; N=256;M=512;s=[-fe/2:fe/M:(fe/2)-1];s1=[1:fe/M:(fe/2)-1];fc1=input('tappez la frquence de coupure fc1=');fc2=input('tappez la frquence de coupure fc2=');% calcule de la frquence impultionelle h(t)L=129;% la longueure de h(t). le nombre d'echantillonsl=[(-L-1)/2:(L-1)/2];%hpb1=(2*fc1/fe)*sinc(2*fc1*l/fe);%hpb2=(2*fc2/fe)*sinc(2*fc2*l/fe);Wn1=2*fc1/fe;% frquence de couppure ,normalise 1Wn2=2*fc2/feWn=[Wn1,Wn2];N1=8;[B,A] = BUTTER(N1,Wn,'stop');[H,W] = FREQZ(B,A,N,fe);fh=abs(H);%h=hpb2-hpb1;for k=1:N x1(k)=cos(2*pi*f0*k/fe); x2(k)=square(2*pi*f0*k/fe); x3(k)=sawtooth(2*pi*f0*k/fe);endy1=filter(B,A,x1);y2=filter(B,A,x2);y3=filter(B,A,x3);%transforme de fourier des signaux filtrsfy11=(abs(fft(y1,M)));fy1=fy11(1:M/2);fy22=(abs(fft(y2,M)));fy2=fy22(1:M/2);fy33=(abs(fft(y3,M)));fy3=fy33(1:M/2);%transforme de fourier de la rponse impulsionnelle%fh=fftshift(abs(fft(h,M)));%transforme de signaux d'entr fx11=(abs(fft(x1,M)));fx1=fx11(1:M/2);fx22=(abs(fft(x2,M)));fx2=fx22(1:M/2);fx33=(abs(fft(x3,M)));fx3=fx33(1:M/2); figure(1)subplot(531),plot(x1),title('x1');subplot(532),plot(x2),title('x2');subplot(533),plot(x3),title('x3');subplot(534),plot(s1,fx1),title('fx1');subplot(535),plot(s1,fx2),title('fx2');subplot(536),plot(s1,fx3),title('fx3');subplot(537),plot(s1,fh),title('fh');subplot(538),plot(s1,fh),title('fh');subplot(539),plot(s1,fh),title('fh');subplot(5,3,10),plot(y1),title('y1');subplot(5,3,11),plot(y2),title('y2');subplot(5,3,12),plot(y3),title('y3');subplot(5,3,13),plot(s1,fy1),title('fy1');subplot(5,3,14),plot(s1,fy2),title('fy2');subplot(5,3,15),plot(s1,fy3),title('fy3');

Reprsentation graphique: