Revision as of 13:00, 4 September 2008 by Cocker (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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 conjugate of c1 type


conj(c1)


You may ask for the real part of a complex number by typing


real(c1)



Imaginary part of the number can be obtained by typing


imag(c1)


To enter a complex matrix, enter it in the same way that you enter a real matrix:


A= [ 2+i 3-5i, -2; -7i 6+7i 55-12i]



This is what you will see


A = 2 + 1i 3 - 5i -2 0 - 7i 6 + 7i 55 - 12i



You may find the real part, imaginary part or the conjugate of a matrix by typing the following commands:


real(A)



imag(A)


conj(A)


To find the conjugate transpose of a matrix use the following command


A'



The commands det(A), rref(A), roots(p) , poly(A), eig(A) work in the same way that they work for real matrices. Note that A' will provide the conjugate transpose of A.


Examples:


Type


B=[2+3i 3-i 5-7i; 9+i 5+i 2-i; 2-i 3-4i 4+i]


To find determinant of B type

det(B)


To find the conjugate transpose of B type

B'


To find coefficients of the characteristic polynomial of B type

poly(B)


To find reduced row echelon form of B type

rref(B)


to find the inverse of B type

inv(B)


to find eigenvalues of B type

eig(B)



to find eigenvalues and eigenvectors of B type

[V D] = eig(B)

Alumni Liaison

Meet a recent graduate heading to Sweden for a Postdoctorate.

Christine Berkesch