Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!b40g2000prf.googlegroups.com!not-for-mail
From: sumnaray@gmail.com
Newsgroups: comp.soft-sys.matlab
Subject: Re: Solving Equation
Date: Fri, 23 Nov 2007 00:28:17 -0800 (PST)
Organization: http://groups.google.com
Lines: 52
Message-ID: <07861df5-d651-414c-8254-0f661a9f2d16@b40g2000prf.googlegroups.com>
References: <d2ea35f2-b295-4b24-a58f-4aa7bf3359ae@s8g2000prg.googlegroups.com> 
NNTP-Posting-Host: 137.99.252.158
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1195806497 5070 127.0.0.1 (23 Nov 2007 08:28:17 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 23 Nov 2007 08:28:17 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: b40g2000prf.googlegroups.com; posting-host=137.99.252.158; 
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) 
Content-Disposition: inline
Xref: news.mathworks.com comp.soft-sys.matlab:438983


On Nov 23, 3:17 am, "Bruno Luong" <brunolu...@yahoo.com> wrote:
> "Bruno Luong" <brunolu...@yahoo.com> wrote in message
>
> <fi6181$8d...@fred.mathworks.com>...> sumna...@gmail.com wrote in message
>
> <d2ea35f2-b295-4b24-a58f-4aa7bf335...@s8g2000prg.googlegroups.com>...> > Hi,
>
> > > How do I solve for X in equation
>
> > > X - MXM' = Q
>
> > > where M, X, and Q are all (n,n) matrix.
>
> > > Thanks.
>
> > See thread on similar problem here (Q was identity)
>
> http://www.mathworks.com/matlabcentral/newsreader/view_thread/159258
>
>
>
> Adapted program:
>
> Bruno
> --------------------------
>
> n=5;
>
> M=rand(n);
> q=rand(n);
> Q=q'*q
>
> Mnlist=cell(1,n);
> Mnlist(:)={M'};
>
> BIGM1=blkdiag(Mnlist{:})';
> BIGM2=reshape(permute(reshape(BIGM1,n,n,n,n),[2 1 4
> 3]),n*n,n*n);
> X=reshape((eye(n*n)-BIGM1*BIGM2)\Q(:),n,n)
> X - M*X*M'

Thanks for your code.

But I am afraid, I still get NaN in my result. I am trying this with

M = [0.5 -0.5 0.5 0; 0 1 0 0; -0.5 -0.5 1.5 0;  0 0 0 0]
and Q as eye(4);

And if you mind me asking, what does [2 1 4 3] mean in BIGM2
expression? I am sorry, I am not very familiar with Matlab.

Thanks again.