How to apply multiple convolutions in one step?
5 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2021 年 6 月 21 日
回答済み: MathWorks Support Team
2021 年 9 月 16 日
I have a matrix of signals where each row corresponds to a signal and I also have a corresponding matrix of filters where each row is a filter.
Thus, each signal has a filter associated with it. How do I apply the corresponding convolutions at once?
採用された回答
MathWorks Support Team
2021 年 6 月 21 日
One way to solve this problem is to convert the filters and signals into cell arrays and make use of 'cellfun' operation to apply row by row convolution.
Assume:
A is the signal matrix where the rows are different signals.
B is the filter matrix with 2 filters
A = [[1 0 1];[1 0 1]];
B = [[2,7];[2,7]];
Convert these matrices into a cell array for faster computation
cellA = num2cell(A, 2)
cellB = num2cell(B,2)
Perform convolution on each row using 'cellfun':
result = cellfun(@(A,B) conv(A, B), cellA,cellb, 'UniformOutput', false);
The last function applies convolution to each row of A with its corresponding filter from B.
'cellfun' applies the desired function (convolution here) to each element of the cell array. More details about 'cellfun' can be found here:
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!