Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Substitute values in data array
Date: Wed, 4 Nov 2009 12:37:02 +0000 (UTC)
Organization: Universit&#228;t Heidelberg
Lines: 22
Message-ID: <hcrshe$1g4$1@fred.mathworks.com>
References: <hcrq6d$mn1$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 1257338222 1540 172.30.248.35 (4 Nov 2009 12:37:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 4 Nov 2009 12:37:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869888
Xref: news.mathworks.com comp.soft-sys.matlab:582343


Dear Florian!

> I want to substitute values in data array and there is a matlab function in the toolbox called changem to o so. 
> However, this function uses a loop:
> 
> for k = 1:numel(newval)
>     B(A == oldval(k)) = newval(k);
> end
> 
> and my array is very large.

Please specify the sizes auf B, A, newval.

> I have tried to speed it up several ways, but no success. Does anyone have an idea how this could be done faster?

Please tell us, what you have tried already. Then we do not have to try it again...

Sometimes FINDSTR is faster than the == operator.
Are there repititions in oldval/newval?
Have you tried to use backwar-indexing (e.g. X(oldval)=newval; B = X(A);), as e.g. in IND2RGB?

Good luck, Jan