1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
| clc
clear all
close all
N=400;%nombre d'étiration
d=zeros(1,N);%initialisation de la reponse désérée
y=zeros(1,N);
se2=zeros(1,N);
t=[60 120 140 180 200];
sg=zeros(1,N);
d(60)=1;
d(120)=1;
d(140)=1;
d(180)=1;
d(200)=1;
p=400;%ordre du filtre
c=40;%alpha
fe=400;%la fréquence d'échantiannage
f=150;%la fréquence du signal
for i=1:N
sg(1,i)=2*exp(-c*i/fe)*sin(2*pi*f*i/fe);%signal amorti
end
%***************************************
g=zeros(5,400);
for i=1:N
if(i>=60)
g(1,i)=sg(1,i-59);%1er signal
end
if(i>=120)
g(2,i)=sg(1,i-119);%2em signal
end
if(i>=140)
g(3,i)=sg(1,i-139);
end
if(i>=180)
g(4,i)=sg(1,i-179);
end
if(i>=200)
g(5,i)=sg(1,i-199);
end
end
for i=1:N
x(i)=g(1,i)+g(2,i)+g(3,i)+g(4,i)+g(5,i);%la sommation des signaux
end
h=ones(1,p); % les coefficient à l'instant initial égaux à zéro
mu=0.02;%la constante :le pas d'adaptation
epsi=0.0001;
test=1;
se2(1)=0;
j=2;
for j=1:360
se2(j)=0;
for n=1:N
%calcul la sortie du filtre
y(n)=0;
for i=1:p
if(n-i>0)
y(n)=y(n)+h(i)*x(n-i);
end
end
%calcul de l'erreur entre la réponse désiré et y
e(n)=d(n)-y(n);
%calcul des coefficient à l'instant n+1
for i=1:p
if(n-i>0)
h(i)=h(i)+mu*x(n-i)*e(n);
end
end
end
for n=1:N
se2(j)=se2(j)+e(n)*e(n);%la sommation des erreurs mise à jour
end
end
figure
subplot(411)
plot(x);
axis([1 N min(x) max(x)])
ylabel('signal s')
subplot(412)
plot(d)
axis([1 N min(d) max(d)])
ylabel('réponse désiré d')
subplot(413)
plot(y);
axis([1 N min(y) max(y)])
ylabel('sortie de filtre y')
subplot(414)
plot(e)
axis([1 N min(e) max(e)])
ylabel('l"erreur e') |
Partager