Path: news.mathworks.com!not-for-mail
From: "Sean de " <sean.dewolski@nospamplease.umit.maine.edu>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Creating a matrix from information in two other matrixes
Date: Fri, 10 Dec 2010 15:45:34 +0000 (UTC)
Organization: University of Maine
Lines: 19
Message-ID: <idthuu$3c1$1@fred.mathworks.com>
References: <idtaut$j28$1@fred.mathworks.com> <idtc4d$ant$1@fred.mathworks.com> <idtgfm$508$1@fred.mathworks.com>
Reply-To: "Sean de " <sean.dewolski@nospamplease.umit.maine.edu>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1291995934 3457 172.30.248.37 (10 Dec 2010 15:45:34 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 10 Dec 2010 15:45:34 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2256903
Xref: news.mathworks.com comp.soft-sys.matlab:694274

"Ulrik Nash" <uwn@sam.sdu.dk> wrote in message <idtgfm$508$1@fred.mathworks.com>...
> "Grzegorz Knor" <gknor@o2.pl> wrote in message <idtc4d$ant$1@fred.mathworks.com>...
> > for example: 
> > 
> > A = [A(1,B(1,:));A(2,B(2,:))]
> > 
> > Grzegorz
> 
> Thanks Grzegorz
> 
> But what if there are n rows. This appears to work only on two rows (I know I provided an example with two rows, but I need to generalize).
> 
> Regards,
> 
> Ulrik.

perhaps

C = bsxfun(@(x,y)x(:,y(1:size(x,1):end)),A,B);