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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
clear all;
close all;
%__________nombre d'itérations____________%
N =26000;
%__________Allocation des variables _______%
FI = zeros(3,N);
X=zeros(3,N);
x1=zeros(1,N);
x2=zeros(1,N);
x3=zeros(1,N);
x1r=zeros(1,N);
x2r=zeros(1,N);
x3r=zeros(1,N);
a0estm=zeros(1,N);
a1estm=zeros(1,N);
b0estm=zeros(1,N);
a0r=zeros(1,N);
a1r=zeros(1,N);
b0r=zeros(1,N);
%_________________système réel___________________%
b0=10^8;
a1=4e3;
a0=10^8;
T=input('Donner la valeur de la période d'échantillonage: ');
%______________________génération du Signal d'entrée_______________________%
I=idinput(N,'PRBS',[0 1/100],[0.0001 10]); %Pseudo Random Binary Signal
%________Fonction continue, Fonction discrète, Géneration du sortie________%
%Fonction de transfert continue
syst=tf(b0,[1 a1 a0]);
t=0:T:25999*T;
Yc=lsim(syst,I,t);
step(syst);% verification de la réponse uindicielle de la fonction de transfert continue
pause
%Fonction de transfert descritisée
SystZ=c2d(syst,T,'tustin');
Yd=lsim(SystZ,I);
step(SystZ);% verification de la réponse uindicielle de la fonction de transfert discritisée
pause
%______________________Génération d'un bruit blanc ________________________%
r=input('Donner le rapport S/B=');
sigma =var(Yd)/(10^(r/10)); % variance du bruit
moy = 0; % moyenne
bruit = moy +sqrt( sigma)*randn(1,N);
%______________Ajout de bruit au signale de sortie (mésuré)________________%
Yd= Yd+bruit';
%les sorties de la fonction de transfert continue et discritisée après
%ajout de bruit
hold on ;
plot(Yc,'b');
plot(I);
plot(Yd,'g');
hold off;
pause
% %_______________________estimation des coefficients de fonction descritisée par moindre carré x1 x2 x3 ________________________%
lamda=0.001;%facteur d'oublie
D=eye(3,3)*lamda;
for k=3:N
FI(:,k)= [ Yd(k-1) Yd(k-2) I(k)+2*I(k-1)+I(k-2)]';
X(:,k)=inv(FI(:,k)'*D*FI(:,k))*FI(:,k)'*D*Yd(k);
end
% calcule des coefficients de la fonction de transfert continue
for k=100:N
x1(k)= X(1,k);
x2(k)= X(2,k);
x3(k)=X(3,k);
c1=b0;
c2=a0+(2*a1/T)+(4/(T^2));
c3=2*a0-(8/(T^2));
c4=a0-(2*a1/T)+(4/(T^2));
x1r(k)=-c3/c2;
x2r(k)=-c4/c2;
x3r(k)=c1/c2;
A=[0 x1(k)+2 2*x1(k)/T ; 0 x2(k)+1 (2*x2(k)/T)-2/T ; -1 x3(k) 2*x3(k)/T ];
B=[(8/(T^2))-(4*x1(k)/(T^2)); (-4*x2(k)/(T^2))-(4/(T^2)) ; -4*x3(k)/(T^2)];
Coeff= inv(A) * B;
b0estm(k)=Coeff(1,:);
a0estm(k)=Coeff(2,:);
a1estm(k)=Coeff(3,:);
b0r(k)=b0;
a0r(k)=a0;
a1r(k)=a1;
end
% %____Plot b0estm/b0r____%
subplot(311);
plot(x1,'b');
hold on;
plot(x1r,'r');
hold off;
% %____Plot b0estm/b0r____%
subplot(312);
plot(x2,'b');
hold on;
plot(x2r,'r');
hold off;
% %____Plot b0estm/b0r____%
subplot(313);
plot(x3,'b');
hold on;
plot(x3r,'r');
hold off;
pause
% %____Plot b0estm/b0r____%
ay1=subplot(311);
plot(b0estm,'b');
hold on;
plot(b0r,'r');
hold off;
ylabel(ay1,'b0');
%____Plot a0oestm/a0r____%
ay4=subplot(312);
plot(a0estm,'b');
hold on, plot(a0r,'r');
grid on;
ylabel(ay4,'a0');
%____Plot a1estm/a1r____%
ay5=subplot(313);
plot(a1estm,'b');
hold on, plot(a1r,'r');
grid on;
ylabel(ay5,'a1');
suptitle('Les coefficients réels et estimés de la fonction de transfert'); |
Partager