Social Icons

Sunday 4 May 2014

Script For inverse of a matrix in Matlab

x=input('Enter a matrix 3*3')
y=input('Enter another 3*3 matrix')
s=x+y
 det=s(1,1)*(s(2,2)*s(3,3)-s(2,3)*s(3,2))-s(1,2)*(s(2,1)*s(3,3)-s(3,1)*s(2,3))+s(1,3)*(s(2,1)*s(3,2)-s(3,1)*s(2,2))
adj=[[(s(2,2)*s(3,3)-s(3,2)*s(2,3));-(s(2,1)*s(3,3)-s(3,1)*s(2,3));(s(2,1)*s(3,2)-s(3,1)*s(2,2))] [-(s(1,2)*s(3,3)-s(3,2)*s(1,3));(s(1,1)*s(3,3)-s(3,1)*s(1,3));-(s(1,1)*s(3,2)-s(3,1)*s(1,2))] [(s(2,2)*s(1,3)-s(1,2)*s(2,3));-(s(1,1)*s(2,3)-s(2,1)*s(1,3));(s(1,1)*s(2,2)-s(2,1)*s(1,2))]]
inverse=(1./det).*adj

No comments:

Post a Comment

 

Sample Text

Sample text

 
Just Programming Cse DriveReputation Management