Path: news.mathworks.com!not-for-mail From: <HIDDEN> Newsgroups: comp.soft-sys.matlab Subject: Re: How do you do this fast? Date: Sat, 12 Jun 2010 02:36:03 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 26 Message-ID: <huurqj$jtj$1@fred.mathworks.com> References: <33a67c34-769a-44db-95c4-1ff9f71dccd9@a42g2000vbl.googlegroups.com> <8bd25c7a-3b59-4b8f-b6a1-8eb1ebbec132@a1g2000vbl.googlegroups.com> Reply-To: <HIDDEN> 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 1276310163 20403 172.30.248.37 (12 Jun 2010 02:36:03 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Sat, 12 Jun 2010 02:36:03 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 1187260 Xref: news.mathworks.com comp.soft-sys.matlab:644350 Luna Moon <lunamoonmoon@gmail.com> wrote in message <8bd25c7a-3b59-4b8f-b6a1-8eb1ebbec132@a1g2000vbl.googlegroups.com>... > ........ > Here is an example: > Originally the data matrix MatrixC is 1000 x 36, so C=[1:36]. > B=[1, 3, 5, 7, 9:36]; so there are 32 numbers in B, they are all > referenced w.r.t. C. > So I have the data matrix MatrixB, consisting of the [1, 3, 5, 7, > 9:36] columns from the original data matrix C. > However, due to costs of measurements, I don't have MatrixC, I have > only measured MatrixB. > I also have A=[1, 5, 9, 11, 13, 25, 31, 33, 34, 35, 36], all the > numbers of which are again referenced w.r.t C. > And A is B's subset. > I would like to obtain > MatrixA=MatrixC(:, A) ideally speaking. > However I don't have MtrixC, I only have MatrixB. > So how do I obtain MatrixA from MatrixB and the index sets A, B, C > without "for" loops? > ....... - - - - - - - Does this do what you want? I too had trouble understanding your question. [ignore,p] = ismember(A,B); matrixA = matrixB(:,B(p)); Roger Stafford