Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Operate on certain element
Date: Thu, 25 Jun 2009 15:17:01 +0000 (UTC)
Organization: Xoran Technologies
Lines: 11
Message-ID: <h204dd$1ts$1@fred.mathworks.com>
References: <h1u7sh$2e7$1@fred.mathworks.com> <h1u8mp$nr5$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1245943021 1980 172.30.248.38 (25 Jun 2009 15:17:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 25 Jun 2009 15:17:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:550611


"Alan B" <monguin61@yahoo.com> wrote in message <h1u8mp$nr5$1@fred.mathworks.com>...

> change = setdiff(1:length(A), dontchange);

Using setdiff() invokes unnecessary sorting operations. 

Steve's method is probably the optimal one , but if you really do need to compute "change" as a set of linear indices, this would probably be better than using setdiff:


change=1:numel(A);
change(dontchange)=[];