微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 微波和射频技术 > 天线设计和射频技术 > Looking for Matlab code for LMS and RLS

Looking for Matlab code for LMS and RLS

时间:04-06 整理:3721RD 点击:
i want matlab code for least-mean squares method (LMS)and recursive least-squares method (RLS).please send it is urgent.

Here is the LMS and RLS matlab codes.....

LMS
xLen = 2000; %sequence length
hLen = 10; %filter length
sigma_w2=0.0; %AWGN power
D=0;
delta=0.06;
c = [1; 0.8]; %channel impulse response
x = rand_sym(sqrt(2), xLen+200, 1); %x=real(x);
d = [zeros(D,1); x]; %take delay into consideration
y = conv(x,c); %y(1:D)=[]; %take delay into consideration
w=sqrt(sigma_w2)/2*(randn(length(y),1)+j*randn(length(y),1));
y=y+w;
ryy=y(101Len+100)'*y(101Len+100)/xLen h=zeros(hLen,1);
h(D+1)=1;
for ii=101Len+100 xhat(ii)=h.'*y(ii:-1:ii-hLen+1);
e(ii)=d(ii)-xhat(ii);
h=h+delta*e(ii)*conj(y(ii:-1:ii-hLen+1));
end
hopt=h eq=conv(c,hopt)
figure(1)
stem(abs(eq))
figure(2)
plot(10*log10(abs(e).^2))
figure(3) plot((abs(e).^2))

RLS
xLen = 2000; %sequence length
hLen = 10; %filter length
sigma_w2=0.0; %AWGN power
D=0;
weight=1;
c = [1; 0.8]; %channel impulse response
x = rand_sym(sqrt(2), xLen+200, 1); %x=real(x);
d = [zeros(D,1); x]; %take delay into consideration
y = conv(x,c); %y(1:D)=[]; %take delay into consideration
w=sqrt(sigma_w2)/2*(randn(length(y),1)+j*randn(length(y),1));
y=y+w;
ryy=y(101Len+100)'*y(101Len+100)/xLen h=zeros(hLen,1);
h(D+1)=1;
Rinv=eye(hLen);
for ii=101Len+100 yvec=y(ii:-1:ii-hLen+1);
xhat(ii)=h.'*yvec;
e(ii)=d(ii)-xhat(ii);
K=Rinv*conj(yvec)/(weight+yvec.'*Rinv*conj(yvec));
Rinv=(Rinv-K*yvec.'*Rinv)/weight;
h=h+K*e(ii);
end
hopt=h eq=conv(c,hopt)
figure(1)
stem(abs(eq))
figure(2)
plot(10*log10(abs(e).^2))
figure(3)
plot((abs(e).^2))

hi.
Can anyone give me the C code for RLS?

what is the meaning of rand_sym, i cannot find it in the matlab program? Can you describe the detail of rand_sym? Or it exits in some toolBox?

Can you describe the detail of rand_sym?

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top