Thread Subject: Inversion of a 21x21 matrix with symbols

Subject: Inversion of a 21x21 matrix with symbols

From: Mehdi Davoudi

Date: 19 Nov, 2009 16:22:19

Message: 1 of 2

Hi,
I want to invert a 21 by 21 matrix that the members are symbols. Do you know how to solve this error?
Matlab shows this error after 1 minute:

??? Error using ==> horzcat
Out of memory. Type HELP MEMORY for your options.

Error in ==> sym.sym>findrun at 562
d = diff([0 x 0]);

Error in ==> sym.sym>char2sym at 453
   [b,e] = findrun(sp); % Beginning (b) and end (e) indices.

Error in ==> sym.sym at 95
   S = char2sym(x);

Error in ==> sym.maple at 92
   result = sym(result,'keepijalias');

Error in ==> sym.inv at 26
   [X,stat] = maple('inverse',A);

Subject: Inversion of a 21x21 matrix with symbols

From: Steven Lord

Date: 19 Nov, 2009 19:31:42

Message: 2 of 2


"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

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
matrix inversio... Mehdi Davoudi 19 Nov, 2009 11:24:22
rssFeed for this Thread

Contact us at files@mathworks.com