I implemented the ERLS algorithm, but it don't identify true. would you help me?

1 次查看(过去 30 天)
clear all close all clc
global N delay Ts format long % ======================== system model ========================== % % continuous model
num = [0.00057 , 380]; den = [0.000000021437 , 0.00007633 , 1];
G = tf(num,den); pole(G); zero(G); syms z;
Ts = 0.02e-03;
Gd = c2d(G,Ts) pole(Gd); zero(Gd);
b = Gd.num{1,1}; a = Gd.den{1,1};
% identification parameters teta = [a(2:3),b(2:3)]' N = 800;
% ======================== RLS with step input ========================== %
% Rand_signal = [0.0025*randn(1,N/4) -0.0025*randn(1,N/4) zeros(1, N/2) ] ; % Rand_signal = [0.091*randn(1,200) zeros(1,600) ] ; % figure(1) % plot([0:N-1]*Ts,Rand_signal)
Rand_signal = [0.091*randn(1,N/4) -0.091*randn(1,N/4) zeros(1, N/2) ] ; % Rand_signal = [0.091*randn(1,200) zeros(1,600) ] ; figure(1) plot([0:N-1]*Ts,Rand_signal)
u = 0.126*ones(1,N) + Rand_signal; figure(2) plot([0:N-1]*Ts,u)
y = system_equation(a,b,u);
teta_hat(:,2) = zeros(4,1); % 4 parameters should be identified M=16; H=1; landa= 0.999; L=4; % R = 1e-6*eye(4,4); %sigma*eye(N).eye(N) R=1e-3*eye(4,4);
r = zeros(4,1); %Rh=z h=zeros(L,N); %solution vector alpha=H; %step size m=1;
for t = 3:N
phi = [-y(t-1) -y(t-2) u(t-1) u(t-2)]';
R= landa*R+ phi*phi';
y_hat (t) = phi'*teta_hat(:,t-1);
error(t) = y(t) - phi'*teta_hat(:,t-1);
z = landa*r+error(t)*phi;
r= z; %residual vector
for k=1:1 %itrations [~,p]=max(abs(r)); while abs(r(p))<=alpha/2*R(p,p) && m<=M m=m+1; alpha=alpha/2; end if m>M % number of bits coeffiecient break end h(p,t)=h(p,t)+sign(r(p))*alpha; r=r-sign(r(p))*alpha*R(:,p); end
h;
teta_hat(:,t) = teta_hat(:,t-1) + h(:,t);
end
teta_hat;
plot1(teta,teta_hat,y,y_hat)
error; cost_function_step = 0.5*(error*error'); norm(teta_hat(:,end)-teta); function y = system_equation(a,b,u)
global N delay
y = zeros(1,N);
% initial conditions y(1) = 0; y(2) = -a(2)*y(1); y(3) = -a(2)*y(2)-a(3)*y(1)+b(2)*u(1)+b(1)*u(2);
for i = 4:N y(i) = -a(2)*y(i-1)-a(3)*y(i-2)+b(2)*u(i-1)+b(3)*u(i-2); end
end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by