Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: inv(rand(6,6,2)) question
Date: Mon, 24 Nov 2008 21:25:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 29
Message-ID: <ggf63f$euo$1@fred.mathworks.com>
References: <ggf2da$898$1@fred.mathworks.com> <ggf2oi$dfo$1@fred.mathworks.com> <ggf39d$mlm$1@fred.mathworks.com> <ggf5ij$61d$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1227561903 15320 172.30.248.37 (24 Nov 2008 21:25:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 24 Nov 2008 21:25:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1376919
Xref: news.mathworks.com comp.soft-sys.matlab:502941


"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <ggf5ij$61d$1@fred.mathworks.com>...
> "Hydroman S" <amirgsalem@gmail.com> wrote in message <ggf39d$mlm$1@fred.mathworks.com>...
> 
> > 
> > fine, now if I put it in a loop, I would think that it would work, but it also doesn't:
> > 
> > for i=1:6
> > x=inv(rand(3,3,i)); 
> > end
> 
> Your loop cannot work
> 
> let's decompose, when i=2
> 
> rand(3,3,i) returns rand(3,3,2).
> 
> Similar issue occurs for i=3,4,5,6.
> 
> It's still a three dimensional array, and MATLAB INV does like it.
> 
> What you need is create the 3D array BEFORE the for-loop, then loop over the last indice. You must put a squeeze somewhere to reduce the dimension.
> 
> I let you figure out how to do that.
> 
> Bruno

Thanks Bruno, let me give it shot...