0
0
MATLABdata~20 mins

Element-wise operations (.*, ./, .^) in MATLAB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Element-wise Operations Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of element-wise multiplication
What is the output of the following MATLAB code?
MATLAB
A = [1 2 3];
B = [4 5 6];
C = A .* B;
disp(C);
A[4 10 18]
B[5 7 9]
C[4 5 6]
D[1 2 3 4 5 6]
Attempts:
2 left
💡 Hint
Remember that .* multiplies each element of A by the corresponding element of B.
Predict Output
intermediate
2:00remaining
Result of element-wise division
What will be displayed after running this MATLAB code?
MATLAB
X = [10 20 30];
Y = [2 4 5];
Z = X ./ Y;
disp(Z);
A[5 5 6.0000]
B[5 4 6]
C[5 5 6]
D[5 5 6.0]
Attempts:
2 left
💡 Hint
Element-wise division divides each element of X by the corresponding element of Y.
Predict Output
advanced
2:00remaining
Output of element-wise power operation
What is the output of this MATLAB code snippet?
MATLAB
P = [2 3 4];
Q = [3 2 1];
R = P .^ Q;
disp(R);
A[6 5 4]
B[8 9 1]
C[8 6 4]
D[8 9 4]
Attempts:
2 left
💡 Hint
The .^ operator raises each element of P to the power of the corresponding element in Q.
Predict Output
advanced
2:00remaining
Error type from wrong operator usage
What error does this MATLAB code produce?
MATLAB
A = [1 2 3];
B = [4 5 6];
C = A * B;
AError: Undefined operator '*' for input arguments of type 'double'.
BError: Inner matrix dimensions must agree.
CNo error, output is [4 10 18].
DError: Matrix dimensions must agree for element-wise multiplication.
Attempts:
2 left
💡 Hint
The * operator is matrix multiplication and requires matching inner dimensions.
🧠 Conceptual
expert
2:00remaining
Number of elements in result after element-wise operations
Given two matrices A (2x3) and B (2x3), what is the number of elements in the result of A .* B?
A6
B2
C3
D1
Attempts:
2 left
💡 Hint
Element-wise operations keep the same size as the input matrices.