Sunteți pe pagina 1din 5

TUGAS PEMROSESAN SINYAL DIGITAL 2

Problem 37

A plot of the squared error is only a rough approximation to the learning curve in the sense
that E[e2(k)] _ e2(k). Write a MATLAB program that uses the DSP Companion function f
lms to identify the following system. For the input use N = 500 samples of white noise
uniformly distributed over [−1, 1], and for the filter order use m = 30.

( )

(a) Use a step size μ that corresponds to .1 of the upper bound in (9.4.16). Print the step size
used.
(b) Compute and print the mean square error time constant in (9.4.29), but in units of
iterations.
(c) Construct and plot a learning curve by performing the system identification M = 50 times
with a different white noise input used each time. Plot the average of the M e2(k) versus k
curves and draw vertical lines at integer multiples of the time constant.

Listing Code :
% Problem 9.37
% Initialize
f_header('Problem 9.37')
m = f_prompt ('Enter filter order m',0,60,30);
N = f_prompt ('Enter number of points N',1,2000,500);
c = f_prompt ('Enter magnitude of noise c',0,4,1);
M = f_prompt ('Enter number of iterations M',1,100,50);
b = [0 0 1 0]
a = [1 0.7 -0.8 -0.56]
% Construct signals
x = f_randu (N,1,-c,c);
d = filter (b,a,x);
% Compute step size
P_x = (1/N)*sum(x.^2);
mu = 0.1/((m+1)*P_x)
% Compute MSE time constant
lambda_min = P_x;
T = 1;
tau_mse = T/(4*mu*lambda_min)
% Find learning curve
E = zeros(N,1);
for i = 1 : M
x = f_randu (N,1,-c,c);
d = filter (b,a,x);
[w,e] = f_lms (x,d,m,mu);
E = E + e.^2;
end
E = E/M;
% Plot learning curve showing time constants
figure
k = 0 : N-1;
plot (k,E)
f_labels ('Learning Curve','k','E[e^2(k)]')
hold on
r = floor (N/tau_mse);
ylim = get (gca,'Ylim');
for i = 1 : r
plot ([i*tau_mse,i*tau_mse],[ylim(1),ylim(2)],'k')
end

Hasil pada command window :


Problem 9.37
Enter filter order m (0 to 60, default: 30): 30
Enter number of points N (1 to 2000, default: 500): 500
Enter magnitude of noise c (0 to 4, default: 1): 1
Enter number of iterations M (1 to 100, default: 50): 50
b=
0 0 1 0
a=
1.0000 0.7000 -0.8000 -0.5600
mu =
0.0099
tau_mse =
77.5000

Grafik yang di tampilkan :


Pembahasan :
Diberikan persamaan fungsi transformasi z, yaitu :
( )
Dengan parameter – parameternya :
Filter order (m) = 30
Number of points (N) = 500
Magnitude of noise (c) =1
Number of iterations (M) = 50
a. Menghitung step size ( )
Menggunakan step size dengan 0.1 dari batas atas pada 9.4.14

( )
Dengan menggunakan white noise dan random signal (x) dengan batasan -1 sampai
dengan 1 sebanyak 500 point (N) yang kemudian difilterkan dengan menggunakan
transformasi z di atas.
Hasil dari random signal (x) digunakan sebagai parameter untuk mencari power input
(P_x), dengan persamaan :

Kemudian power input yang dihasilkan digunakan untuk menghitung step size dengan
menggunakan persamaan 9.4.14 di atas, disini nilai digunakan untuk memastikan
convergence sehingga ditulis :

( )
Jadi , hasil yang di dapatkan ialah 0,0099 dan dapat disimpulkan bahwa nilai
stepsize bergantung pada orde filter dan power input.

b. Menghitung MSE time constant dengan menggunakan persamaan 9.4.27

Nilai disini sama dengan


Problem 42

Listing Code :
% Problem 9.42
% Initialize
f_header('Problem 9.42')
m = f_prompt ('Enter filter order m',0,100,40);
gamma = f_prompt ('Enter forgetting factor gamma',0,1,0.9);
N = f_prompt ('Enter number of points N',1,2000,200);
M = f_prompt ('Enter number of samples to predict ahead M',0,40,20);
c = f_prompt ('Enter magnitude of white noise c',0,1,0.05);
% Construct input and desired output
k = [0 : N-1]';
v = f_randu(N,1,-c,c);
x = sin(pi*k/20).*cos(pi*k/10) + v;
d = x;
x_M = zeros(size(x));
x_M(M+1:N) = x(1:N-M);
% Compute the optimal weights
[w,e] = f_rls (x_M,d,m,gamma);
% Plot learning curve
figure
plot (k,e.^2)
f_labels ('Learning Curve','k','e^2(k)')
f_wait
% Plot input and output
y = filter (w,1,x);
figure
subplot (2,1,1)
fill ([160 180 180 160],[-2 -2 2 2],'c')
hold on
plot (k,x)
f_labels ('Input and Output','k','x(k)')
subplot (2,1,2)
fill ([140 160 160 140],[-2 -2 2 2],c')
hold on
plot (k,y)
f_labels ('','k','y(k)')
f_wait
Hasil pada command window :
Problem 9.42
Enter filter order m (0 to 100, default: 40): 40
Enter forgetting factor gamma (0 to 1, default: 0.9): 0.9
Enter number of points N (1 to 2000, default: 200): 200
Enter number of samples to predict ahead M (0 to 40, default: 20): 20
Enter magnitude of white noise c (0 to 1, default: 0.05): 0.05

Grafik yang dihasilkan :

S-ar putea să vă placă și