Home » Source Code » » Example_2.m

## Example_2.m ( File view )

From：
• By 2010-08-22
• View(s)：15
• Point(s)： 1
			clear;
alpha=0.5;  % Stepsize of NLMS
mu_lms=0.3; % Stepsize of LMS
M=5;
k=0:99;
x=cos(pi*k/100).*sin(pi*k/5);
b=[1,0,-1];
a=[1,1,0.9];
d=filter(b,a,x);
delta=0.05;
[e,w,mu_k]=nlms(alpha,M,x,d,delta);
[e_lms,w_lms]=lms(mu_lms,M,x,d);
[c,i]=max(mu_k);

%------------------------------------------------
subplot(3,1,1);
stem(k,x,'.');
hold on;
plot(k,cos(pi*k/100),'--','color','m');
title('Normalized LMS Method','fontsize',18)
ylabel('x(k)','fontsize',14);
grid on;
subplot(3,1,2);
stem(k,mu_k,'.');
text(i,c,'\leftarrow Peak Value');
ylabel('\mu(k)','fontsize',14);
grid on;
subplot(3,1,3);
stem(k,abs(e),'.');
ylabel('e(k)','fontsize',14);
xlabel('k','fontsize',14);
grid on;

%-------------------------------------------
mu_lms_vec=mu_lms*ones(1,100);
figure(2);
subplot(2,1,1);
stem(k,mu_k,'.');
ylim([0,10]);
title('Difference between NLMS and LMS','fontsize',18);
text(i,c,'\leftarrow Peak Value');
ylabel('\mu(k)','fontsize',14);
xlabel('NLMS','fontsize',14);
grid on;
subplot(2,1,2);
stem(k,mu_lms_vec,'.');
ylim([0,10]);
ylabel('\mu','fontsize',14);
xlabel('LMS','fontsize',14);
grid on;
%-------------------------------------------
y_nlms=filter(w,1,x);
y_lms=filter(w_lms,1,x);
% Compute the Frequency Response
D=fft(d);
Y_nlms=fft(y_nlms);
Y_lms=fft(y_lms);
f=0:0.01:0.99;

figure(3)
subplot(2,1,1);
plot(k,d,k,y_nlms,'r',k,y_lms,'g');
title('The waveform in time domain','fontsize',16);
ylabel('Amplitude','fontsize',14);
subplot(2,1,2);
plot(f,abs(D),f,abs(Y_nlms),'r',f,abs(Y_lms),'g');
title('Magnitude Response','fontsize',16);
xlabel('Normalized frequence','fontsize',12);
grid on;

figure(4)
subplot(2,1,1);
stem(k,abs(e),'.');
title('Error Comparison between NLMS and LMS','fontsize',18);
ylabel('e(k)','fontsize',14);
xlabel('NLMS','fontsize',14);
grid on;
subplot(2,1,2)
stem(k,abs(e_lms),'.')
ylabel('e(k)','fontsize',14);
xlabel('LMS','fontsize',14);
grid on;

...
Expand＞ ＜Close

Point(s): 1

0 lines left, continue to read

## File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
Example_2.m2.08 kB28-08-08 20:55
nlms.m691.00 B28-08-08 20:54
<nlms>0.00 B30-09-08 12:27
...
• Sent successfully!
• 1 point
×

### Example_2.m (1.53 kB)

Need 1 point

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

×

Don't have an account？ Register now
Need any help?
Mail to: support@codeforge.com
×

### 切换到中文版？

CodeForge Chinese Version
CodeForge English Version
×

×

### ^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
×

### Warm tip!

Favorite by Ctrl+D