フィルターのクリア

How to write a function which performs deconvolution to solve for x given y and h where y = h*x (all column vectors) using linsolve

3 ビュー (過去 30 日間)
William
William 2021 年 9 月 20 日
回答済み: Nipun 2024 年 5 月 23 日
I do know that the deconv() function can do it perfectly. However, I was wondering if anyone can write a function with linsolve() to perform deconvolution. I have tried to make a simple implementation but it seems to be not universal.
function x = mdeconv(h, y)
%Deconvolution
%
hT = toeplitz([h(1) zeros(1,length(y)-length(h))], [h zeros(1,length(y)-length(h)) ]);
%x = linsolve(hT, y);
x = y/hT;
end

回答 (1 件)

Nipun
Nipun 2024 年 5 月 23 日
Hi William,
I understand that you are trying to perform deconvolution using the linsolve function instead of the deconv function in MATLAB. Below is a modified version of your function to use linsolve for deconvolution:
function x = mdeconv(h, y)
% Deconvolution using linsolve
%
% Inputs:
% h - Impulse response
% y - Convolved signal
%
% Output:
% x - Deconvolved signal
% Create the Toeplitz matrix for h
hT = toeplitz([h(:); zeros(length(y)-length(h), 1)], [h(1), zeros(1, length(y)-1)]);
% Solve for x using linsolve
x = linsolve(hT, y(:));
% Ensure the result is a row vector if y was a row vector
if isrow(y)
x = x.';
end
end
Refer to the following MathWorks documentation for more information on creating Toeplitz matrix in MATLAB: https://in.mathworks.com/help/matlab/ref/toeplitz.html#d126e1740357
Hope this helps.
Regards,
Nipun

カテゴリ

Help Center および File ExchangeDigital Filtering についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by