|
"Mehdi Davoudi" <davoodii@gmail.com> wrote in message
news:he3rbr$9pg$1@fred.mathworks.com...
> Hi,
> I want to invert a 21 by 21 matrix that the members are symbols. Do you
> know how to solve this error?
Yes. Don't invert the matrix (use backslash, \, if you're trying to solve a
system of equations for which the 21-by-21 matrix is the matrix of
coefficients), or if you must substitute values into the matrix for as many
of the symbolic variables as you can before trying to invert it.
The expressions for the elements of the inverse of a 2-by-2 matrix are
fairly short:
>> syms a b c d
>> M = inv([a b;c d])
M =
[ d/(a*d - b*c), -b/(a*d - b*c)]
[ -c/(a*d - b*c), a/(a*d - b*c)]
But things start getting much more complicated once you start working with
larger matrices
>> syms a b c d e f g h k
>> M = inv([a b c;d e f;g h k])
M =
[ (f*h - e*k)/(a*f*h - b*f*g - c*d*h + c*e*g - a*e*k + b*d*k), -(c*h -
b*k)/(a*f*h - b*f*g - c*d*h + c*e*g - a*e*k + b*d*k), -(b*f - c*e)/(a*f*h -
b*f*g - c*d*h + c*e*g - a*e*k + b*d*k)]
[ -(f*g - d*k)/(a*f*h - b*f*g - c*d*h + c*e*g - a*e*k + b*d*k), (c*g -
a*k)/(a*f*h - b*f*g - c*d*h + c*e*g - a*e*k + b*d*k), (a*f - c*d)/(a*f*h -
b*f*g - c*d*h + c*e*g - a*e*k + b*d*k)]
[ -(d*h - e*g)/(a*f*h - b*f*g - c*d*h + c*e*g - a*e*k + b*d*k), (a*h -
b*g)/(a*f*h - b*f*g - c*d*h + c*e*g - a*e*k + b*d*k), -(a*e - b*d)/(a*f*h -
b*f*g - c*d*h + c*e*g - a*e*k + b*d*k)]
For a general 21-by-21 matrix, the expressions for the coefficients would be
quite large and difficult to read.
--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
|