Conv2 explanation for specific example
4 views (last 30 days)
Show older comments
Hey Guys, i need some help for the conv2 implementation for given problem:
K>> conv2([1 2 3], [1 0 0], 'full')
ans =
1 2 3 0 0
Why are the zeros on the right side? Does varies with the border depending on the kernel-center?
For this example its clear:
K>> conv2([1 2 3], [1 0 1], 'full')
ans =
1 2 4 2 3
Thanks for your help, Leo
0 Comments
Answers (4)
Jan
on 26 Jul 2011
Because you have vectors, your example is equivalent to:
conv([1, 2, 3], [1, 0, 0])
E.g. the last element of the result is "w(2*n-1) = u(n)*v(n)", which is 0 in your example. Perhaps your are searchng for the 'same' or 'valid' shapes?
2 Comments
Jan
on 26 Jul 2011
Indeed?
In Matlab 6.5 it called FILTER after reordering the inputs: CONV(A, B) equals CONV(B, A), but FILTER(B, 1, A) is faster, if length(A) < length(B).
I think I should read through all of the toolbox functions again...
the cyclist
on 26 Jul 2011
Isn't the convolution calculation essentially doing what I have written below? Does that make it clearer where the zeros come from?
a = [1 2 3]
b = [1 0 0]
conv_a_b = b(1)*[a 0 0] + b(2)*[0 a 0] + b(3) * [0 0 a]
0 Comments
Leo
on 26 Jul 2011
1 Comment
the cyclist
on 26 Jul 2011
In response to what you said to Jan: There is no "padding". MATLAB is treating the trailing zeros in "b" exactly how it would treat them if they were non-zero, and giving you the result.
In response of what you said to me: Yes. What I typed is functional code, using the "a" that you defined.
See Also
Categories
Find more on Performance and Memory 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!