Challenge - 5 Problems
Vector Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this MATLAB code?
Consider the following MATLAB code that creates a row vector and a column vector. What will be the size of
B after execution?MATLAB
A = [1, 2, 3, 4]; B = A';
Attempts:
2 left
💡 Hint
Remember that the apostrophe (') operator transposes the vector.
✗ Incorrect
The vector A is a row vector with size 1x4. Transposing it with ' converts it into a column vector with size 4x1.
❓ Predict Output
intermediate2:00remaining
What is the output of this MATLAB code?
What will be the output of the following code snippet?
MATLAB
v = [5; 10; 15]; result = v(2);
Attempts:
2 left
💡 Hint
Indexing in MATLAB starts at 1 and works down the column for column vectors.
✗ Incorrect
The vector v is a column vector with elements 5, 10, and 15. Accessing v(2) returns the second element, which is 10.
❓ Predict Output
advanced2:00remaining
What is the output of this MATLAB code involving vector multiplication?
Given the row vector
r = [1 2 3] and column vector c = [4; 5; 6], what is the result of r * c?MATLAB
r = [1 2 3]; c = [4; 5; 6]; result = r * c;
Attempts:
2 left
💡 Hint
Matrix multiplication rules: number of columns in first must equal number of rows in second.
✗ Incorrect
r is 1x3 and c is 3x1, so multiplication is valid and results in a 1x1 scalar: 1*4 + 2*5 + 3*6 = 32.
❓ Predict Output
advanced2:00remaining
What error does this MATLAB code produce?
What error will this code produce?
MATLAB
r = [1 2 3]; c = [4 5 6]; result = r * c;
Attempts:
2 left
💡 Hint
Check the dimensions of the vectors for matrix multiplication.
✗ Incorrect
Both r and c are 1x3 row vectors. Multiplying two 1x3 matrices is invalid because the inner dimensions do not match.
🧠 Conceptual
expert2:00remaining
How many elements are in the resulting vector?
If you create a row vector
R = 1:7 and a column vector C = (1:7)', what is the number of elements in the vector V = R + C'?Attempts:
2 left
💡 Hint
Check the dimensions of R, C, and C' before addition.
✗ Incorrect
R is a 1x7 row vector, C is a 7x1 column vector, so C' is 1x7 row vector. Adding two 1x7 vectors results in a 1x7 vector with 7 elements.