Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Simple matrix manipulation question
Date: Thu, 16 Jul 2009 21:27:01 +0000 (UTC)
Organization: Xoran Technologies
Lines: 14
Message-ID: <h3o5v5$d8c$1@fred.mathworks.com>
References: <h3lt89$b6e$1@fred.mathworks.com> <h3o275$2h9$1@fred.mathworks.com> <h3o2o3$7g4$1@fred.mathworks.com> <h3o46t$f27$1@fred.mathworks.com> <h3o54v$hc9$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1247779621 13580 172.30.248.35 (16 Jul 2009 21:27:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 16 Jul 2009 21:27:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:556105


"Matt Fig" <spamanon@yahoo.com> wrote in message <h3o54v$hc9$1@fred.mathworks.com>...
> I can see no difference in speed (nan vs. inf), but Matt's solution is incomplete as I understand the problem.
> 
> 
> % Data
> N = 1200;
> A = round(rand(N)*20);
> B = randperm(N);

It's because randperm() produces a row vector, whereas I assume B is a column vector (as did the OP). When you insert

B=B(:);

all 3 methods come into agreement.