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!