Path: news.mathworks.com!not-for-mail
From: "John D'Errico" <woodchips@rochester.rr.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Solving AM = MB
Date: Tue, 14 Oct 2008 22:35:03 +0000 (UTC)
Organization: John D'Errico (1-3LEW5R)
Lines: 25
Message-ID: <gd36qn$sl9$1@fred.mathworks.com>
References: <gd34pk$csc$1@fred.mathworks.com>
Reply-To: "John D'Errico" <woodchips@rochester.rr.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1224023703 29353 172.30.248.37 (14 Oct 2008 22:35:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 14 Oct 2008 22:35:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869215
Xref: news.mathworks.com comp.soft-sys.matlab:495188


"David Doria" <daviddoria@gmail.com> wrote in message <gd34pk$csc$1@fred.mathworks.com>...
> I would like to solve AM = MB where A,B,M are 3x3 matrices.
> 
> What I came up with was to equate every entry in C to the corresponding entry in D (where C = AM and D = MB).
> 
> You can then vectorize M (call it Mv) and figure out the 9 equations to fill a 9x9 matrix on both sides
> 
> 9x9 matrix times Mv = 9x9 matrix times Mv
> 
> Each row on the right can be subtracted from the same row on the left, leaving
> 
> 9x9 times Mv = 0
> 
> The problem is, I could construct this matrix easily by hand, but this seems like an obnoxious process to write in code (a couple of loops or something?) Is there a better/different way to do this so that I can use some built in functions?


This gets asked every once in a while.
So I wrote a function to do it. There is
nice trick inside to build the necessary
matrices.

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=19614&objectType=FILE

HTH,
John