How to apply multiple convolutions in one step?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 21 Juin 2021
Réponse apportée : MathWorks Support Team
le 16 Sep 2021
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?
Réponse acceptée
MathWorks Support Team
le 21 Juin 2021
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 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!