how to deconvolute a array ?
20 views (last 30 days)
Show older comments
Rabih Sokhen
on 8 Feb 2022
Commented: Chris Turnes
on 11 Feb 2022
hy guys
i would like to deconvolute a matrix
code:
clear all
clc
a=rand(10,3);
b=rand10,3); %b=conv2(a,c)
%suppose that b is already the convolution of the array "a" with an array "c"
% I would like to deconvulte " b " to re-obtain "a" and "c".
% any idea how to do so?
% thanks you in advance
0 Comments
Accepted Answer
Chris Turnes
on 9 Feb 2022
Deconvolution is equivalent to polynomial division. You can get the polynomial division and its remainder with the deconv function.
rng('default');
% Take two vectors.
a = randn(7,1);
c = randn(10,1);
% Compute their convolution.
b = conv(a, c);
% "Recover" the first by deconvolving c from b:
[ahat,r] = deconv(b, c);
% Check the residual and the remainder polynomial
norm(a-ahat)
r'
However, it's important to note that this is not a least-squares solution to the deconvolution, and if b isn't really the result convolving something with c, you may not get an answer that's particularly close to the least squares result. To get the least squares result, you would construct the Toeplitz system corresponding to the convolution and solve it:
% Add some "noise" to c:
bhat = conv(a, c + 1e-3*randn(size(c)));
% Solve with deconv:
ahat_deconv = deconv(bhat, c);
% Compare convolving the result with c against the vector we started with:
norm(bhat - conv(ahat_deconv, c))
% Solve with least-squares:
T = convmtx(c, length(a));
ahat_ls = T \ bhat;
% Compare convolving the least-squares result with c against the vector we
% started with:
norm(bhat - conv(ahat_ls, c))
There are efficient algorithms to solve the Toeplitz system, though there are not any functions directly in MATLAB to do so.
8 Comments
Chris Turnes
on 11 Feb 2022
Your error here is that you're not specifying the right size for the convolution matrix. The size argument is the size of the thing you are convolving with a -- so in this case, the size of b. You've alredy determined this later, so you just need to pass it into the function:
a = randn(5, 7);
c = randn(13,17);
szB = size(c) - size(a) + 1;
b= full(convmtx2(a, szB) \ c(:));
b= reshape(b, szB);
More Answers (0)
See Also
Categories
Find more on Working with Signals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!