A complex number in MATLAB is a number that has a real part and an imaginary part, written as a + bi where a is the real part and b is the imaginary part.
Click to reveal answer
beginner
How do you create a complex number with real part 3 and imaginary part 4 in MATLAB?
You can create it by writing z = 3 + 4i; or z = complex(3,4);.
Click to reveal answer
beginner
What MATLAB function returns the magnitude (absolute value) of a complex number?
The function abs(z) returns the magnitude of the complex number z.
Click to reveal answer
intermediate
How do you get the phase (angle) of a complex number in MATLAB?
Use the function angle(z) to get the phase in radians of the complex number z.
Click to reveal answer
intermediate
What does the MATLAB function conj(z) do?
It returns the complex conjugate of z, which flips the sign of the imaginary part.
Click to reveal answer
Which of the following is a valid way to create a complex number in MATLAB?
Az = 5 + 2i;
Bz = 5 + 2j;
Cz = complex(5, 2);
DAll of the above
✗ Incorrect
MATLAB supports both i and j as imaginary units and the complex function to create complex numbers.
What does abs(3 + 4i) return in MATLAB?
A7
B5
C1
D12
✗ Incorrect
The magnitude is sqrt(3^2 + 4^2) = 5.
What is the output of angle(1 + 1i) in MATLAB (in radians)?
Api/4
B0
Cpi/2
Dpi
✗ Incorrect
The angle of 1 + 1i is 45 degrees or pi/4 radians.
What does conj(2 - 3i) return?
A2 - 3i
B-2 + 3i
C2 + 3i
D-2 - 3i
✗ Incorrect
The conjugate flips the sign of the imaginary part.
Which function would you use to extract the real part of a complex number z in MATLAB?
Areal(z)
Bangle(z)
Cabs(z)
Dimag(z)
✗ Incorrect
The real(z) function returns the real part of z.
Explain how to create and manipulate complex numbers in MATLAB.
Think about how you write complex numbers and what functions help you get their parts or properties.
You got /4 concepts.
Describe the difference between the magnitude and phase of a complex number and how to find them in MATLAB.
Imagine a point on a plane and how far and at what angle it is from the origin.
You got /4 concepts.
Practice
(1/5)
1. Which of the following correctly represents a complex number with real part 3 and imaginary part 4 in MATLAB?
easy
A. 3 + 4
B. 3i + 4
C. 3 + 4i
D. 3 + 4j + 1
Solution
Step 1: Understand complex number format in MATLAB
Complex numbers are written as real part plus imaginary part times i or j, e.g., 3 + 4i.
Step 2: Check each option
3 + 4i uses 3 + 4i which is correct. 3 + 4 misses imaginary part. 3i + 4 swaps real and imaginary incorrectly. 3 + 4j + 1 adds extra 1.
Final Answer:
3 + 4i -> Option C
Quick Check:
Complex number = 3 + 4i [OK]
Hint: Use 'i' or 'j' after the imaginary part number [OK]
Common Mistakes:
Forgetting to include 'i' or 'j' for imaginary part
Swapping real and imaginary parts
Adding extra numbers outside complex format
2. Which of the following MATLAB commands correctly creates a complex number variable named z with real part 5 and imaginary part -2?
easy
A. z = complex(5, -2);
B. z = 5 + 2i;
C. z = 5 + -2;
D. z = 5 - 2;
Solution
Step 1: Recall MATLAB syntax for complex numbers
Using complex(real, imag) function is a clear way to create complex numbers.
Step 2: Analyze options
z = 5 - 2; is just a real number. z = 5 + 2i; creates 5 + 2i (wrong imaginary part). z = 5 + -2; is a real number. z = complex(5, -2); uses complex(5, -2) correctly.
Final Answer:
z = complex(5, -2); -> Option A
Quick Check:
complex(5, -2) creates correct complex number [OK]
Hint: Use complex(real, imag) for clear complex number creation [OK]
Common Mistakes:
Writing imaginary part without 'i' or 'j'
Using wrong sign for imaginary part
Confusing syntax of complex() function
3. What is the output of the following MATLAB code?
z1 = 2 + 3i; z2 = 1 - 4i; result = z1 * z2;
medium
A. 10 - 5i
B. 14 - 5i
C. 14 + 5i
D. 10 + 5i
Solution
Step 1: Multiply complex numbers (a+bi)(c+di)
Use formula: (ac - bd) + (ad + bc)i. Here a=2, b=3, c=1, d=-4.