0
$\begingroup$

Here is an example of convolution given:

enter image description here

I have two questions here:

  1. Why is the vector 𝑥 padded with two 0s on each side? As, the length of kernel is 3. If 𝑥 is padded with one 0 on each side, the middle element of convolution output would be within the range of the length of 𝑥, why not one 0 on each side?

  2. Explain the following output to me:

     >> x = [1, 2, 1, 3];  
     >> h = [2, 0, 1];  
     >> y = conv(x, h, 'valid')      
      y =    
          3     8  
     >>   
    

    What is valid doing here in the context of the previously shown mathematics on vectors 𝑥 and ?

$\endgroup$
  • $\begingroup$ See this answer for a detailed explanation of what is going on in an actual convolution (first table in your question). As to what valid means in the context of MATLAB, I have no idea. $\endgroup$ – Dilip Sarwate Oct 27 '18 at 15:35
  • $\begingroup$ I would suggest to type "help conv" at the Matlab prompt and read the documentation. It describes exactly what "valid", "full" and "same" mean. If that doesn't answer your question, please post back with a question about what you don't understand in Matlab's documention $\endgroup$ – Hilmar Oct 27 '18 at 17:59
1
$\begingroup$

For your second question, valid means the range of output where there is full overlap between the convolving signals.

Note that for two causal signals, $x[n]$ of length $L_x$ and $h[n]$ of length $L_h$ the convolution output $y[n]$ will be of length $L_y = L_x + L_h -1$.

However among those output $y[n]$ samples, the first $L_d = \min\{L_x,L_h\} -1$ and the last $L_d= \min\{L_x,L_h\} -1$ samples will be computed with partial overlaps between $x[n]$ and $y[n]$ (whicih are the edge samples) but the remaining portion (that's in the center) will be be computed by full overlap with the shorter sequence being fully inside the longer sequence.

In your case; $L_x = 4$ and $L_h=3$ then the first and last $2$ samples will be discarded and the center $2$ samples will be returned.

$\endgroup$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.