Forums

Matlab for LMS (least mean squar)

Started by nasser alshuaili November 19, 2002


> Iam trying to write matlab script for LMS for first order system
and
> i got problm to complete the matlab scripts
> please could anyone help#
> ***********************************
> %assume y(k)=0.6(z^-1) u(k)/(1+0.5z^-1)
> %y(k)=-0.5y(k-1)+0.6u(k-1). >>>shifting>> y(k+1)=-0.5y(k)+0.6u(k)
> %Note LMS w^(n+1)=w(n)+*u(n)*e(n). 02/lamda lamda=max
> eign
> value of R=u*u'
> % % To generate input signal
> u=idinput(1101);
>
> %To generate output
> for k =1
> y(k)=0;
> y(k+1)=-0.5*y(k)+0.6*u(k);
> end
> for k = 2:1100,
> y(k+1)=-0.5*y(k)+0.6*u(k);
> end
> figure
> subplot(2,1,1); plot(u);title ('Input signal');
> subplot(2,1,2); plot(y);title ('Output signal');
> y=y(:); %to get the transpose of matrix y
> % y% select portion from 100 to 1100 (number of coloums in u and y
> matrics00)
>
> u=u(101:1100);
> y=y(101:1100);
> z=[y,u];
> figure
> plot(z);title ('Input/Output signal');
> *************************