Convolution of every row in matrix.
Mostrar comentarios más antiguos
I need to find a way to convolute rows of a matrix together into a single vector. For example: If I have a matrix A = [1,2;3,4;5,6] need a function that will produce a vector B = conv(conv(A(1,:) , A(2,:)), A(3,:))
Is there any function that could do that? If no, could someone help me write a loop to do it for me?
Thanks
Respuestas (1)
Andrei Bobrov
el 30 de Nov. de 2016
Editada: Andrei Bobrov
el 30 de Nov. de 2016
A = reshape(1:6,2,[])';
[m,n] = size(A);
B = zeros(1,m*(n-1)+1);
B(1:n) = A(1,:);
for ii = 1:size(A,1)-1
B(1:n-ii+ii*n) = conv(B(1:ii*n-ii+1),A(ii+1,:));
end
6 comentarios
Calle Swedhag
el 30 de Nov. de 2016
Editada: Calle Swedhag
el 30 de Nov. de 2016
Image Analyst
el 30 de Nov. de 2016
Seems like a very strange thing to do. What are you after? What's the real world use of this? Are you trying to demonstrate the Central Limit Theorem or something???
And how many rows get convolved? Just 3 at a time, like your initial example showed, until you hit the bottom? Or all of them from the first row down, like k nested convolutions?
Calle Swedhag
el 30 de Nov. de 2016
Calle Swedhag
el 30 de Nov. de 2016
Image Analyst
el 30 de Nov. de 2016
Convolution is not multiplying poynomials together. What your nested convolution will produce is a gigantic Gaussian. That's what the central limit theorem guarantees. Any function(s), almost no matter what shape, if convolved more than about 5 or 6 times will look very close to a Gaussian.
Andrei Bobrov
el 30 de Nov. de 2016
I corrected my answer.
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!