Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Looking for Matlab code for LMS and RLS

Status
Not open for further replies.

jaydon.jayant

Newbie level 6
Joined
Jan 31, 2008
Messages
11
Helped
0
Reputation
0
Reaction score
1
Trophy points
1,281
Activity points
1,338
i want matlab code for least-mean squares method (LMS)and recursive least-squares method (RLS).please send it is urgent.
 

Re: smart antenna

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(101:xLen+100)'*y(101:xLen+100)/xLen h=zeros(hLen,1);
h(D+1)=1;
for ii=101:xLen+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(101:xLen+100)'*y(101:xLen+100)/xLen h=zeros(hLen,1);
h(D+1)=1;
Rinv=eye(hLen);
for ii=101:xLen+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))
 
Re: smart antenna

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?
 

Re: smart antenna

Can you describe the detail of rand_sym?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top