(New page: MATLAB and Complex Numbers Examples To start you may type Format rat i =sqrt(-1) Matlab will return ans = To enter a complex number type c1= 4+5i To find the...) |
|||
Line 1: | Line 1: | ||
− | MATLAB and Complex Numbers Examples | + | ==MATLAB and Complex Numbers Examples == |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | Defining terms in matlab | ||
i =sqrt(-1) | i =sqrt(-1) | ||
− | |||
Matlab will return | Matlab will return | ||
+ | ans = 0 + 1i | ||
+ | EX. | ||
+ | a= 3+2i | ||
+ | Finding the conjugate | ||
+ | conj(a) | ||
+ | Finding the real part | ||
+ | real(a) | ||
+ | Finding the imaginary part | ||
+ | imag(a) | ||
+ | ==Sample Code== | ||
+ | >> a=3+2i | ||
+ | a =3.0000 + 2.0000i | ||
− | + | >> conj(a) | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | conj( | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | ans =3.0000 - 2.0000i | ||
+ | >> real(a) | ||
+ | ans =3 | ||
− | + | >> imag(a) | |
− | + | ans =2 |
Revision as of 13:07, 4 September 2008
MATLAB and Complex Numbers Examples
Defining terms in matlab i =sqrt(-1)
Matlab will return ans = 0 + 1i
EX. a= 3+2i Finding the conjugate conj(a) Finding the real part real(a) Finding the imaginary part imag(a)
Sample Code
>> a=3+2i
a =3.0000 + 2.0000i
>> conj(a)
ans =3.0000 - 2.0000i
>> real(a)
ans =3
>> imag(a)
ans =2