sumnaray@gmail.com wrote in message
<d2ea35f2-b295-4b24-a58f-4aa7bf3359ae@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)
On Nov 23, 2:58 am, "Bruno Luong" <brunolu...@yahoo.com> wrote:
> 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
>
> Bruno
Actually, I did try that, but I got
NaN NaN NaN 0
NaN NaN NaN 0
NaN NaN -Inf 0
NaN NaN 0 1
"Bruno Luong" <brunoluong@yahoo.com> wrote in message
<fi6181$8dm$1@fred.mathworks.com>...
> sumnaray@gmail.com wrote in message
>
<d2ea35f2-b295-4b24-a58f-4aa7bf3359ae@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'
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.
sumnaray@gmail.com wrote in message <d2ea35f2-b295-4b24-
a58f-4aa7bf3359ae@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.
-------
This should do it:
U = repmat(M,n,n);
K = floor((n:n^2+n-1)/n);
V = conj(M(K,K));
X = reshape((eye(n^2)-U.*V)\Q(:),n,n);
If M is real-valued, the 'conj' operation is unnecessary.
"Bruno Luong" <brunoluong@yahoo.com> wrote in message
<fi63hb$2o0$1@fred.mathworks.com>...
> sumnaray@gmail.com wrote in message
>
> >
> > 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]
>
> In order the problem to be well-posed, the input M needs to
> be a full-rank matrix (inversible). Your matrix isn't. That
> is why you get NaN.
>
Wait a minute, I'm not certain about this statement. I think
that the condition on M for well-posed is more complex than
that.
Bruno
Tags for this Thread
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.
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.