Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
http://eeweb.poly.edu/iselesni/lecture_notes/least_squares/Lea...
Contents
Start
Create data
Output data
Convolution matrix H
Direct solve (fails)
Diagonal loading (noise-free)
Diagonal loading (noisy)
Derivative regularization (noisy)
Start
clear
close all
Create data
N = 300;
n = (0:N-1)';
% n : discrete-time index
w = 5;
n1 = 70;
n2 = 130;
x = 2.1 * exp(-0.5*((n-n1)/w).^2) - 0.5*exp(-0.5*((n-n2)/w).^2).*(n2 - n);
h = n .* (0.9 .^n) .* sin(0.2*pi*n);
% x : input
% h : impulse response
figure(1)
clf
subplot(2, 1, 1)
plot(x)
title('Input signal');
YL1 = [-2 3];
ylim(YL1);
subplot(2, 1, 2)
plot(h)
title('Impulse response');
1 of 8
2015-11-15, 10:55 PM
http://eeweb.poly.edu/iselesni/lecture_notes/least_squares/Lea...
Output data
randn('state', 0);
y = conv(h, x);
y = y(1:N);
figure(2)
clf
subplot(2, 1, 1)
plot(y);
YL2 = [-7 13];
ylim(YL2);
title('Output signal');
subplot(2, 1, 2)
plot(yn);
title('Output signal (noisy)');
ylim(YL2);
2 of 8
2015-11-15, 10:55 PM
http://eeweb.poly.edu/iselesni/lecture_notes/least_squares/Lea...
Convolution matrix H
Create convolution matrix H and verify that H*x is the same as y
H = convmtx(h, N);
H = H(1:N, :);
% H : convolution matrix
ans =
0
H is singular
3 of 8
2015-11-15, 10:55 PM
http://eeweb.poly.edu/iselesni/lecture_notes/least_squares/Lea...
g(1:10)
ans =
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
4 of 8
2015-11-15, 10:55 PM
http://eeweb.poly.edu/iselesni/lecture_notes/least_squares/Lea...
5 of 8
2015-11-15, 10:55 PM
http://eeweb.poly.edu/iselesni/lecture_notes/least_squares/Lea...
lam = 1.0;
g = (H'*H + lam * eye(N)) \ (H' * yn);
figure(2)
clf
subplot(2, 1, 1)
plot(g)
ylim(YL1)
title(sprintf('Deconvolution (diagonal loading, \\lambda = %.2f)', lam));
lam = 5.0;
g = (H'*H + lam * eye(N)) \ (H' * yn);
subplot(2, 1, 2)
plot(g)
ylim(YL1)
title(sprintf('Deconvolution (diagonal loading, \\lambda = %.2f)', lam));
6 of 8
2015-11-15, 10:55 PM
http://eeweb.poly.edu/iselesni/lecture_notes/least_squares/Lea...
% second-order difference
First corner of D
full(D(1:5, 1:5))
ans =
1
0
0
0
0
-2
1
0
0
0
1
-2
1
0
0
0
1
-2
1
0
0
0
1
-2
1
Last corner of D
full(D(end-4:end, end-4:end))
ans =
1
-2
7 of 8
0
1
0
0
0
0
0
0
2015-11-15, 10:55 PM
1
0
0
-2
1
0
http://eeweb.poly.edu/iselesni/lecture_notes/least_squares/Lea...
1
-2
1
0
1
-2
0
0
1
8 of 8
2015-11-15, 10:55 PM