Challenge - 5 Problems
Signal Routing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateWhat is the output of this signal routing code?
Consider the following MATLAB code that routes signals through a switch matrix. What will be the value of
outputSignal after execution?MATLAB
inputSignal = [1 2 3 4]; switchMatrix = [0 1 0 0; 1 0 0 0; 0 0 0 1; 0 0 1 0]; routeIndex = 2; outputSignal = inputSignal * switchMatrix(routeIndex, :)';
Attempts:
2 left
💡 Hint
Remember that MATLAB matrix multiplication rules apply and the switchMatrix row selects which inputSignal elements are routed.
✗ Incorrect
The code multiplies the inputSignal vector by the second row of switchMatrix transposed. The second row is [1 0 0 0], so the multiplication sums inputSignal elements weighted by this row: 1*1 + 2*0 + 3*0 + 4*0 = 1. But since inputSignal is a row vector and switchMatrix(row,:) is a row vector, the multiplication inputSignal * switchMatrix(routeIndex, :)' results in a scalar equal to 1.
🧠 Conceptual
intermediateWhich statement correctly describes signal routing in MATLAB?
In MATLAB, when routing signals using matrices, which of the following statements is true?
Attempts:
2 left
💡 Hint
Think about how matrix multiplication can select and combine signals.
✗ Incorrect
In MATLAB, signal routing can be efficiently done by multiplying an input signal vector by a routing matrix. The routing matrix acts as a selector or switch, directing inputs to outputs by matrix multiplication.
🔧 Debug
advancedIdentify the error in this signal routing code
The following MATLAB code is intended to route signals from
inputSignal to outputSignal using routingMatrix. What error will occur when running this code?MATLAB
inputSignal = [1 2 3]; routingMatrix = [0 1 0; 1 0 0]; outputSignal = inputSignal * routingMatrix;
Attempts:
2 left
💡 Hint
Check the sizes of the matrices involved in multiplication.
✗ Incorrect
inputSignal is a 1x3 vector, routingMatrix is 2x3. Multiplying 1x3 by 2x3 is invalid because inner dimensions must match (3 and 2 do not). This causes a dimension mismatch error.
❓ Predict Output
advancedWhat is the output of this complex routing example?
Given the following MATLAB code, what is the value of
outputSignal?MATLAB
inputSignal = [10 20 30 40]; routingMatrix = [1 0 0 0; 0 0 1 0; 0 1 0 0; 0 0 0 1]; outputSignal = routingMatrix * inputSignal';
Attempts:
2 left
💡 Hint
Remember that inputSignal is a row vector and is transposed to a column vector before multiplication.
✗ Incorrect
routingMatrix is 4x4 and inputSignal' is 4x1. Multiplying routingMatrix by inputSignal' results in a 4x1 vector. The routingMatrix rearranges the inputSignal elements: first row picks element 1 (10), second row picks element 3 (30), third row picks element 2 (20), fourth row picks element 4 (40).
🚀 Application
expertHow many output signals are produced by this routing matrix?
Given the routing matrix below, how many output signals will be generated when routing an input vector of length 5?
MATLAB
routingMatrix = [1 0 0 0 0; 0 1 0 0 0; 0 0 1 0 0; 0 0 0 1 0];
Attempts:
2 left
💡 Hint
The number of output signals corresponds to the number of rows in the routing matrix.
✗ Incorrect
The routing matrix has 4 rows and 5 columns. When multiplying by an input vector of length 5, the output vector length equals the number of rows, which is 4.
