0
0
MATLABdata~10 mins

Complex numbers 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 create a complex number with real part 3 and imaginary part 4.

MATLAB
z = 3 + [1] * 4;
Drag options to blanks, or click blank then click option'
Aj
Bi
Ck
Dm
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable other than i or j for the imaginary unit.
Forgetting to multiply the imaginary unit by the imaginary part.
2fill in blank
medium

Complete the code to calculate the magnitude of the complex number z.

MATLAB
magnitude = [1](z);
Drag options to blanks, or click blank then click option'
Aabs
Bmag
Cmod
Dlength
Attempts:
3 left
💡 Hint
Common Mistakes
Using length which returns the size of an array, not magnitude.
Using mod which is for modulus operation on integers.
3fill in blank
hard

Fix the error in the code to get the phase angle of the complex number z.

MATLAB
angle_value = [1](z);
Drag options to blanks, or click blank then click option'
Aphase
Batan
Carg
Dangle
Attempts:
3 left
💡 Hint
Common Mistakes
Using phase which is not a MATLAB function.
Using arg which is not recognized in MATLAB.
4fill in blank
hard

Fill both blanks to create a complex number from magnitude 5 and angle pi/4.

MATLAB
z = [1] * (cos([2]) + 1i * sin(pi/4));
Drag options to blanks, or click blank then click option'
A5
Bpi/4
Cpi/2
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong angle value inside cosine and sine.
Confusing magnitude with angle.
5fill in blank
hard

Fill all three blanks to create a vector of complex numbers with real parts 1 to 3 and imaginary parts 4 to 6.

MATLAB
z = [1] + [2] * [3];
Drag options to blanks, or click blank then click option'
A1:3
B1i
C4:6
D1j
Attempts:
3 left
💡 Hint
Common Mistakes
Using 1j instead of 1i (both work but only one is correct here).
Mixing up the ranges for real and imaginary parts.