How to estimate the parameters of Hammerstein model online?

May 12, 2004 0 Replies

I want to estimate the parameters of Hammerstein model online, the matlab code is as follows. But, the estimated paramters are wrong, they can not be used by the controller. Please help me!



function [A,B,Ca,Cb]=arma3(A0,B0,C0,C1,y,u,m) na=m(1); nb=m(2); nc=m(3); if isempty(A0)|isempty(B0) p=2*eye(na+nb+nc); %6 2:3:3 th=zeros(na+nb+nc,1);%6 else th=zeros(1,na+nb+nc+nc); p=100000*eye(na+nb+nc+nc);



% th(1:length(A0)+length(B0)+length(C0))=[A0,B0,C0]; end



lthy=length(y); lthu=length(u); lambda=0.9999;


%Piv=inv(p); %nmax=max(na,nb); ndata = length(y);



for i=4 :ndata % for i=(1+nmax):ndata ydata =-[y(i-1);y(i-2)]; % udata = [u(i);u(i-1);u(i-2)]'; udata = [u(i);u(i-1);u(i-2)]';



% rdata=[u(i)^(2);u(i)*u(i-1);u(i)*u(i-2);u(i)*u(i-3);... % u(i)^(3);u(i)^(2)*u(i-1);u(i-2)*u(i)^(2);u(i-3)*u(i)^(2)]; % rdata=[u(i)^(2);u(i-1)^(2);u(i-2)^(2)];



rdata=[u(i)^(2);u(i-1)^(2);u(i-2)^(2);... u(i)^(3);u(i-1)^(3);u(i-2)^(3)];



zeta = [ydata(:); udata(:);rdata]; nrm=(lambda+zeta'*p*zeta); p = (p - p*zeta*zeta'*p/nrm)/lambda; th = (th' + p*zeta*(y(lthy) - zeta'*th'))'; end %th=sum(zeta*y(lthy))./sum(zeta*zeta'); %th=th+0.14*zeta'*(y(lthy) - zeta'*th');



if (na > 1) A = [1,th(1:length(A0)-1)]; %A = [1,th(1:na-1)]; else A = 1; end



if (nb > 0) B = th(length(A0):length(A0)+length(B0)-1);



%B = th(na:na+nb-1); else B = []; end if (nc > 0) Ca = th(length(A0)+length(B0):length(A0)+length(B0)+length(C0)-1);



%B = th(na:na+nb-1); else C = []; end if (nc > 0) Cb = th(length(A0)+length(B0)+length(C0):length(A0)+length(B0)+length(C0)+length(C0)-1);



% B = th(na:na+nb-1); else C = []; end


Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required