Challenge - 5 Problems
Special Matrices Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of zeros and ones matrix operations
What is the output of the following MATLAB code?
A = zeros(2,3); B = ones(3,2); C = A * B; disp(C);
MATLAB
A = zeros(2,3); B = ones(3,2); C = A * B; disp(C);
Attempts:
2 left
💡 Hint
Remember that zeros multiplied by any number results in zeros.
✗ Incorrect
Matrix A is 2x3 zeros, B is 3x2 ones. Multiplying zeros by ones results in a 2x2 zero matrix.
❓ Predict Output
intermediate2:00remaining
Eye matrix diagonal values
What does the following MATLAB code display?
I = eye(4); disp(I(2,2)); disp(I(2,3));
MATLAB
I = eye(4); disp(I(2,2)); disp(I(2,3));
Attempts:
2 left
💡 Hint
Eye matrix has ones on the diagonal and zeros elsewhere.
✗ Incorrect
I(2,2) is on the diagonal, so it is 1. I(2,3) is off-diagonal, so it is 0.
🔧 Debug
advanced2:00remaining
Identify the error in matrix creation
What error does this MATLAB code produce?
M = zeros(3); N = ones(2,3); P = M + N;
MATLAB
M = zeros(3); N = ones(2,3); P = M + N;
Attempts:
2 left
💡 Hint
Check the sizes of M and N before adding.
✗ Incorrect
M is 3x3, N is 2x3, so addition is invalid due to dimension mismatch.
❓ Predict Output
advanced2:00remaining
Random matrix value range
What is the range of values produced by this MATLAB code?
R = rand(2,2); disp(min(R(:))); disp(max(R(:)));
MATLAB
R = rand(2,2); disp(min(R(:))); disp(max(R(:)));
Attempts:
2 left
💡 Hint
rand generates numbers in the interval (0,1).
✗ Incorrect
rand produces uniformly distributed random numbers strictly greater than 0 and less than 1.
🧠 Conceptual
expert2:00remaining
Number of elements in special matrices
How many elements does the matrix created by
eye(5,3) contain in MATLAB?Attempts:
2 left
💡 Hint
Count total elements in a 5-by-3 matrix.
✗ Incorrect
eye(5,3) creates a 5 rows by 3 columns matrix, so total elements = 5*3 = 15.