0
0
MATLABdata~10 mins

Element-wise operations (.*, ./, .^) in MATLAB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to multiply each element of vectors A and B element-wise.

MATLAB
C = A [1] B;
Drag options to blanks, or click blank then click option'
A.*
B./
C.+
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using * instead of .* causes matrix multiplication, which may error if dimensions mismatch.
2fill in blank
medium

Complete the code to divide each element of vector X by corresponding element of Y element-wise.

MATLAB
Z = X [1] Y;
Drag options to blanks, or click blank then click option'
A.\
B/
C\
D./
Attempts:
3 left
💡 Hint
Common Mistakes
Using / performs matrix division, not element-wise division.
3fill in blank
hard

Fix the error in the code to raise each element of vector V to the power of 3 element-wise.

MATLAB
W = V [1] 3;
Drag options to blanks, or click blank then click option'
A^
B.*
C.^
D./
Attempts:
3 left
💡 Hint
Common Mistakes
Using ^ performs matrix power, which is not element-wise.
4fill in blank
hard

Fill both blanks to compute element-wise multiplication and then element-wise division of vectors A and B.

MATLAB
result = (A [1] B) [2] B;
Drag options to blanks, or click blank then click option'
A.*
B+
C./
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using + or - instead of element-wise multiplication or division.
5fill in blank
hard

Fill all three blanks to compute element-wise power, then multiply element-wise, and finally divide element-wise.

MATLAB
output = ((X [1] 2) [2] Y) [3] Z;
Drag options to blanks, or click blank then click option'
A.^
B.*
C./
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using + instead of element-wise operators.
Mixing matrix operators with element-wise operators.