How can I use conv() in a function handle and keep original vector size, but not use 'same'/'valid'?
Show older comments
Hi! I am trying to use conv() inside a function handle, while keeping the original vector size of one of the vectors:
So in the example code I convolve a and b, which returns c as [1,4,10,16,22,28,27,18].
I want this to be [1,4,10], as it is the size of a.
This is my code, which does not work:
a = [1,2,3]
b = [1,2,3,4,5,6]
c = @(x) conv(a,b(x(1)))(1:numel(a))
The following does work, but requires multiple lines (which unfortunately is not possible with function handles, so not an option for me):
c = conv(a,b)
c = c(1:numel(a))
If I use 'same' or 'valid', the output is not the same as using conv() and keeping the first columns of the original vector.
using 'same' returns: [16,22,28], using 'valid' returns: [ ], both not [1,4,10].
All help would be appreciated! :)
Accepted Answer
More Answers (0)
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!