Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!news2.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe02.iad.POSTED!7564ea0f!not-for-mail
From: Doug Schwarz <see@sig.for.address.edu>
Newsgroups: comp.soft-sys.matlab
Subject: Re: inv(rand(6,6,2)) question
References: <ggf2da$898$1@fred.mathworks.com> <ggf2oi$dfo$1@fred.mathworks.com> <ggf39d$mlm$1@fred.mathworks.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
User-Agent: MT-NewsWatcher/3.5.2 (Intel Mac OS X)
Message-ID: <see-21B979.16365724112008@news.frontiernet.net>
Lines: 45
X-Complaints-To: abuse-news@frontiernet.net
NNTP-Posting-Date: Mon, 24 Nov 2008 21:36:49 UTC
Organization: Frontier
Date: Mon, 24 Nov 2008 16:36:57 -0500
Xref: news.mathworks.com comp.soft-sys.matlab:502948


In article <ggf39d$mlm$1@fred.mathworks.com>,
 "Hydroman S" <amirgsalem@gmail.com> wrote:

> "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message 
> <ggf2oi$dfo$1@fred.mathworks.com>...
> > "Hydroman S" <amirgsalem@gmail.com> wrote in message 
> > <ggf2da$898$1@fred.mathworks.com>...
> > 
> > > 
> > > shouldn't each of the 2 matrcies in  rand(6,6,2) give us a separate 
> > > inverse? 
> > > 
> > 
> > No.
> > 
> > Bruno
> 
> 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
> 
> ??? Error using ==> inv
> Input arguments must be 2-D.

Think about what you are doing.  The first time through the loop you 
generate a 3x3x1 matrix and that works.  The second time through the 
loop you generate a 3x3x2 matrix and that doesn't work.

What you want to do is generate the matrix once and then pick each plane 
in turn:

  A = rand(6,6,n);
  for i = 1:n
      B(:,:,i) = inv(A(:,:,i));
  end

(Of course, you probably shouldn't be using inverses in the first place.)

-- 
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.