Easy convolution of multiple vectors

조회 수: 7 (최근 30일)
Daniel
Daniel 2014년 9월 23일
댓글: Matt J 2014년 9월 23일
For the convolution of three vectors I'm doing:
A = [1 2];
B = [3 4];
C = [5 6];
res_aux = conv(A,B);
res = conv(res_aux,C);
Is there an easier way? Something like: res = multiconv({A,B,C})
An alternative would be using cellfun but it's slower.

채택된 답변

Matt J
Matt J 2014년 9월 23일
편집: Matt J 2014년 9월 23일
Here's an fft-based approach
data=[1 2;3 4;5 6].';
n=(size(data,1)-1)*size(data,2)+1;
result = ifft(prod(fft(data,n),2),'symmetric')
  댓글 수: 2
Daniel
Daniel 2014년 9월 23일
Thank you Matt!
I had read about using fft to solve this but I couldn't understand how. Your comment was of great help.
I'm marking this as answered. Once again, thank you!
Matt J
Matt J 2014년 9월 23일
OK. I'm not sure it's faster/more efficient than a plain for-loop, though. It involves complex-valued arithmetic and probably about 4 times more memory consumption.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by