Challenge - 5 Problems
Convolution Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of 1D convolution with simple vectors
What is the output of the following MATLAB code?
x = [1 2 3];
h = [0 1 0.5];
y = conv(x, h);
disp(y);
MATLAB
x = [1 2 3]; h = [0 1 0.5]; y = conv(x, h); disp(y);
Attempts:
2 left
💡 Hint
Remember convolution flips the second vector and slides it over the first.
✗ Incorrect
The convolution of x and h results in a vector of length length(x)+length(h)-1 = 5. Calculating stepwise gives [0 1 2.5 4 1.5].
❓ Predict Output
intermediateOutput length of convolution
Given two vectors in MATLAB:
What is the output?
a = ones(1,4);
b = ones(1,3);
c = conv(a,b);
length_c = length(c);
disp(length_c);
What is the output?
MATLAB
a = ones(1,4); b = ones(1,3); c = conv(a,b); length_c = length(c); disp(length_c);
Attempts:
2 left
💡 Hint
The length of the convolution output is length(a) + length(b) - 1.
✗ Incorrect
The output length is 4 + 3 - 1 = 6.
❓ Predict Output
advanced2D convolution output matrix
What is the output of this MATLAB code?
A = [1 2; 3 4];
B = [0 1; 1 0];
C = conv2(A, B);
disp(C);
MATLAB
A = [1 2; 3 4]; B = [0 1; 1 0]; C = conv2(A, B); disp(C);
Attempts:
2 left
💡 Hint
Remember conv2 output size is (m+p-1) x (n+q-1) for matrices m x n and p x q.
✗ Incorrect
The convolution result is a 3x3 matrix. Calculating each element gives [[0 1 2]; [1 5 4]; [3 4 0]].
❓ Predict Output
advancedEffect of convolution with impulse
What is the output of this MATLAB code?
x = [4 5 6];
impulse = [1 0 0];
y = conv(x, impulse);
disp(y);
MATLAB
x = [4 5 6]; impulse = [1 0 0]; y = conv(x, impulse); disp(y);
Attempts:
2 left
💡 Hint
Convolution with an impulse shifts and extends the signal.
✗ Incorrect
Convolution length is length(x)+length(impulse)-1 = 3+3-1=5. The output is [4 5 6 0 0].
❓ Predict Output
expertConvolution with complex vectors output
What is the output of this MATLAB code?
x = [1+1i, 2+2i];
h = [1-1i, 0];
y = conv(x, h);
disp(y);
MATLAB
x = [1+1i, 2+2i]; h = [1-1i, 0]; y = conv(x, h); disp(y);
Attempts:
2 left
💡 Hint
Multiply and sum complex numbers carefully for convolution.
✗ Incorrect
Convolution length is 3. Calculations: y(1) = (1+1i)*(1-1i)=2+0i; y(2) = (1+1i)*0 + (2+2i)*(1-1i) = 4 + 0i; y(3) = (2+2i)*0=0.
