Cody

Problem 43494. Weighted Convolution

Created by Peng Liu in Community

Given two input vectors x = [x_1, x_2, ..., x_K] and y = [y_1, y_2, ..., y_K] of equal length, compute the weighted convolution output z = [z_1, z_2, ..., z_K], where

     z_k = sum(nchoosek(k-1,j-1)*x_{k-j+1}*y_j, j = 1..k),  k = 1, 2, ..., K

Example: x = [1, 2, 3]; y = [4, 5, 6]. Then z = [z_1, z_2, z_3] where

z_1 = nchoosek(0,0)*1*4 = 4
z_2 = nchoosek(1,0)*2*4 + nchoosek(1,1)*1*5 = 13
z_3 = nchoosek(2,0)*3*4 + nchoosek(2,1)*2*5 + nchoosek(2,2)*1*6 = 38

Hint: This can be seen as the linear convolution weighted by the binomial coefficient. It is straightforward to solve this problem using a for loop. I am wondering if there exists some more elegant way (e.g., vectorization) to do this.

Solution Stats

85.71% Correct | 14.29% Incorrect
Last solution submitted on Feb 09, 2019

Problem Comments

Recent Solvers11

Suggested Problems

More from this Author43

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!