||'''Book'''|| Getting started with MATLAB || ||'''Author'''|| Rudra Pratap || ||'''Edition'''|| || /* code_begins */ {{{ var('r') A=matrix([[5,2*r,r],[3,6,2*r-1],[2,r-1,3*r]]) print "Matrix A is given as:\n",A b=matrix([[2],[3],[5]]) print "Matrix b is given as:\n",b var('x1,x2,x3') X=matrix([[x1],[x2],[x3]]) print "Matrix X is given as:\n",X print "To solve matrix AX=b ,find inverse for A" print "Inverse is only possible if the matrix is non-singular i.e determinant of matrix is not zero." x(r)=A.det() print "Determinant of A \nx(r)=",x(r) print "To solve this problem consider any valid value for r.For instance consider r=1.So x(1)=",x(1) K1=A(1) Result: Matrix A is given as: [ 5 2*r r] [ 3 6 2*r - 1] [ 2 r - 1 3*r] Matrix b is given as: [2] [3] [5] Matrix X is given as: [x1] [x2] [x3] To solve matrix AX=b ,find inverse for A Inverse is only possible if the matrix is non-singular i.e determinant of matrix is not zero. Determinant of A x(r)= -5*(r - 1)*(2*r - 1) + 3*(r - 1)*r + 4*(2*r - 1)*r - 18*r^2 + 78*r To solve this problem consider any valid value for r.For instance consider r=1.So x(1)= 64 A(1)= [5 2 1] [3 6 1] [2 0 3] X=(A(1).inverse)*b Resultant matrix X= [-1/32] [15/64] [27/16] Value of x1= (-1/32) Value of x2= (15/64) Value of x3= (27/16) print "A(1)=\n" ,K1 K=A(1).inverse() print "X=(A(1).inverse)*b" print "Resultant matrix X=\n",K*b X=K*b print "Value of x1=",X[0] print "Value of x2=",X[1] print "Value of x3=",X[2] }}} /* code_ends */ * '''Solution by''': * , ,