0% found this document useful (0 votes)
13 views3 pages

Mathematic 2

The document provides an overview of complex numbers in MATLAB, including their definition, creation, and arithmetic operations. It explains how to create complex numbers using both direct assignment and the complex function, as well as how to perform basic arithmetic operations like addition, subtraction, multiplication, and division. Additionally, it covers MATLAB functions for extracting real and imaginary parts, computing the complex conjugate, and calculating the absolute value of complex numbers.

Uploaded by

saifgoran037
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

Mathematic 2

The document provides an overview of complex numbers in MATLAB, including their definition, creation, and arithmetic operations. It explains how to create complex numbers using both direct assignment and the complex function, as well as how to perform basic arithmetic operations like addition, subtraction, multiplication, and division. Additionally, it covers MATLAB functions for extracting real and imaginary parts, computing the complex conjugate, and calculating the absolute value of complex numbers.

Uploaded by

saifgoran037
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Mathematics II – Practical (Matlab) IT Department First Stage \ Second Semester

9- Complex Numbers
Complex numbers consist of two separate parts: a real part and an imaginary part. The
basic imaginary unit is equal to the square root of -1. This is represented in MATLAB by
either of two letters: i or j.
>> i
ans =
0.0000 + 1.0000i

>> j
ans =
0.0000 + 1.0000i

>> sqrt(-1)
ans =
0.0000 + 1.0000i

Creating Complex Numbers


The following statement shows one way of creating a complex value in MATLAB. The
variable z is assigned a complex number with a real part of 2 and an imaginary part of 3:

>> z=2+3i
z =
2.0000 + 3.0000i
>> z=-4-5j
z =
-4.0000 - 5.0000i
Another way to create a complex number is using the complex function. This function
combines two numeric inputs into a complex output, making the first input real and the
second imaginary.

>> x = 4;
>> y = -2;
>> z = complex(x,y)
z =
4.0000 - 1.0000i

6
Mathematics II – Practical (Matlab) IT Department First Stage \ Second Semester

Arithmetic operations with complex numbers


We can add, subtract, multiply and divide two or more complex numbers by Matlab codes,
as follows:

>> z1=2+3i;
>> z2=4-5i;

>> z1+z2
ans =
6.0000 - 2.0000i

>> z1-z2
ans =
-2.0000 + 8.0000i

>> z1*z2
ans =
23.0000 + 2.0000i

>> z1/z2
ans =
-0.1707 + 0.5366i

Matlab Functions for Complex Numbers


In Matlab, the function real(z) returns the real part and imag(z) returns the
imaginary part:
>> z=6-8i;

>> x=real(z)
x =
6

>> y=imag(z)
y =
-8

7
Mathematics II – Practical (Matlab) IT Department First Stage \ Second Semester

Also, the function conj(z) computes the complex conjugate of the complex number z,
and the function abs(z) computes the absolute value of z:

>> z=3+4i;

>> conj(z)
ans =
3.0000 - 4.0000i

>> abs(z)
ans =
5

10 - Display Format
MATLAB has several different screen output formats for displaying numbers. These
formats can be found by typing the help command: help format in the Command Window.
A few of these formats are shown in Table

You might also like