Complete the code to create a complex number with real part 3 and imaginary part 4.
z = 3 + [1] * 4;
In MATLAB, the imaginary unit is commonly represented by j or i. Here, j is used.
Complete the code to calculate the magnitude of the complex number z.
magnitude = [1](z);length which returns the size of an array, not magnitude.mod which is for modulus operation on integers.The abs function in MATLAB returns the magnitude (or absolute value) of a complex number.
Fix the error in the code to get the phase angle of the complex number z.
angle_value = [1](z);phase which is not a MATLAB function.arg which is not recognized in MATLAB.The MATLAB function angle returns the phase angle (in radians) of a complex number.
Fill both blanks to create a complex number from magnitude 5 and angle pi/4.
z = [1] * (cos([2]) + 1i * sin(pi/4));
The complex number in polar form is magnitude times (cos(angle) + i*sin(angle)). Here, magnitude is 5 and angle is pi/4.
Fill all three blanks to create a vector of complex numbers with real parts 1 to 3 and imaginary parts 4 to 6.
z = [1] + [2] * [3];
1j instead of 1i (both work but only one is correct here).The vector z is created by adding the real parts 1:3 to the imaginary parts 4:6 multiplied by the imaginary unit 1i.