Saturday 29 August 2015

INVERSE AND ADJOINT OF A MATRIX USING MATLAB

INVERSE OF MATRIX:

matrix inverse can be found out by using the formula

                                               inverse of A = adj(A)/det(A)

adj(A) - adjoint matrix of A

But there is a direct code to find out the Inverse of the matrix

command:
             
               A = [1 4 5; 6 6 8 ; 1 3 7 ]
               B = inv(A)

 the output is


This is how inverse of a matrix can be found.

ADJOINT MATRIX CAN BE FOUND OUT BY

command:  

adj(A) = det(A)*inv(A)

the output is


This is how adjoint matrix can be found 

ROUND,FLOOR,FIX,CEIL COMMANDS

Round:
 Rounds towards nearest integer
COMMANDS:
round(2.3) 
round(2.6)
the output is
  Screenshot (19)

the output of round(2.3) is 2 because the nearest integer for 2.3 is 2
 the output of round(2.6) is 3 because the nearest integer for 2.6 is 3
 Floor:
 it rounds towards negitive infinity code:

floor(2.7)
the output is

  Screenshot (20)

output is 2 because nearest integer in the direction of negitive infinity is 2

 ceil:
        it round towards positive infinity code:
ceil(2.3)
output is

  Screenshot (21)output is 3 because nearest integer in the direction of positive infinity is 3

 fix:
          rounds the number towards zero code:
fix(-1.3) 
fix(1.3)
the output is Screenshot (22) fix(-1.3) gives output -1 because nearest integer in  the direction of zero is -1
 fix(1.3) give s output 1 because nearest integer in the direction of zero is 1
 These are 4 commands to round numbers

DETERMINANT OF A MATRIX USING MATLAB

determinant of a matrix is used to check the singularity
 singular  if det value is 0
non singular if det value is not zero
it is also used to say about invertibility of a matrix

code for determinant:
a = [ 1 5 7 ; 2 3 4 ; 5 7 3] 
det(a)
The output is

  Screenshot (18)

by this we can find the determinant of matrix

TRANSPOSE OF MATRIX USING MATLAB

TRANSPOSE OF MATRIX: ( DONE USING 3 X 3 MATRIX)  

Matrix transpose means Interchanging Rows and columns

 code:
a = [1 2 3 ;4  5  6 ; 7 8 9] 
b = a'                                             ("  '  "  is used for transposing)
output is
  Screenshot (17)

This is how matrix transposing is done

OPERATIONS ON MATRICES USING MATLAB

code for adding two matrices:  ( '+' operator is used for summing two matrices)

a = [ 1 2 3 ; 4 5 6 ; 7 8 9] 
b= [ 1 0 0 ; 0 1 0; 0 0 1] 
c = a+b
Screenshot (14)

code for matrix subtraction: ('-' operator is used for subtraction. It is done using 2x2 matrices)
a = [ 2  2 ; 4  4] 
b = [1   0 ; 0  0] 
c = a-b

Screenshot (15)

multiplying matrices: (' * 'operator is used for multiplication)
a = [ 1  2  ; 3  4 ] 
b = [ 1 0 ; 0  1] 
c = a*b

Screenshot (16)

INTRODUCTION TO MATRICES IN MATLAB

Basics of Matrices Row Matrix  :

row matrix:

a matrix which has only one row.
 example:  [1  2  3]

 column Matrix :

 a matrix which has only one column
 example    [ 1
                      2
                      3 ]

 square matrix:

has equal number of rows and columns

 ex: a=[  2      2
               4     4   ]

 this a 2 x 2 matrix rectangular matrix: matrix which has unequal columns and rows

 ex: a = [2  2  2
              4  4  4 ]

 coding for initializing the each of the above matrices: 

row matrix initializing
a = [1  2  3]                                 (this initilizes a row matrix)
column matrix initializing:
b = [1 ; 2 ; 3]                          (';' is used to end a particular row)
square matrix initializing:
c = [2   2   ;  4   4]
rectangular matrix initializing:
d = [2   2   2 ; 4   4   4]
the output is Screenshot (13)

OPERATION ON VARIABLES IN MATLAB

code for summing of 2 Variables: (write in m- file or commmand window)
a = 10                             (initilizing "a ") 
b =20                               (initilizing "b")
          c = a+b                             ('+' operator is used for summing two  variables')                                        
this is the code used for summing of 2 variables and storing result in variable c the output  is

  Screenshot (10)

Subtraction code:
a=10 
b=5 
c=a-b
the output is

  Screenshot (11)

 multiplying and dividing:
a=10 
b=5  
c=a*b                    ( '*' operator is used for subtraction) 
d=a/b                     (' / ' operator is used for division)
The output is
  Screenshot (12)

the arthematic operation are performed as shown in above examples