Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: inv(rand(6,6,2)) question
Date: Mon, 24 Nov 2008 21:16:03 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 24
Message-ID: <ggf5ij$61d$1@fred.mathworks.com>
References: <ggf2da$898$1@fred.mathworks.com> <ggf2oi$dfo$1@fred.mathworks.com> <ggf39d$mlm$1@fred.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
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 1227561363 6189 172.30.248.37 (24 Nov 2008 21:16:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 24 Nov 2008 21:16:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:502937


"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