Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
ismember alternative?

Subject: ismember alternative?

From: Kenneth Cutter

Date: 15 Apr, 2004 09:51:40

Message: 1 of 4

I have a big simulation that uses "ismember" thousands of times in a run.
I have found that this is taking a significant amount of execution time.
The function is working on numeric inputs only.
Can anyone suggest a (possibly) faster-running alternative?

Thanks

--
Kenneth Cutter

Advanced Information Engineering Services,
a General Dynamics Company

MIT Lincoln Laboratory
Group 34- Intelligence, Test and Evaluation
781-981-2839

cutter@ll.mit.edu

Subject: ismember alternative?

From: Peter Boettcher

Date: 15 Apr, 2004 10:08:04

Message: 2 of 4

Kenneth Cutter <cutter@ll.mit.edu> writes:

> I have a big simulation that uses "ismember" thousands of times in a run.
> I have found that this is taking a significant amount of execution time.
> The function is working on numeric inputs only.
> Can anyone suggest a (possibly) faster-running alternative?

Ken, I think you'll need to post a small snippet of code that shows
how you're using it.


--
Peter Boettcher <boettcher@ll.mit.edu>
MIT Lincoln Laboratory
MATLAB FAQ: http://www.mit.edu/~pwb/cssm/

Subject: ismember alternative?

From: rayn@mathworks.com (raymond s. norris)

Date: 15 Apr, 2004 10:48:42

Message: 3 of 4

[This followup was posted to comp.soft-sys.matlab and a copy was sent to
the cited author.]

hi kenneth-

if you're calling ISMEMBER as such:

   status = ismember(7,[1 2 3 ...]);

then you could replace it with

   status = any(7==[1 2 3 ...]);

hth,
-raymond

In article <Imwfc.159$9m.108@llnews.ll.mit.edu>, cutter@ll.mit.edu
says...
> I have a big simulation that uses "ismember" thousands of times in a run.
> I have found that this is taking a significant amount of execution time.
> The function is working on numeric inputs only.
> Can anyone suggest a (possibly) faster-running alternative?
>
> Thanks
>
> --
> Kenneth Cutter
>
> Advanced Information Engineering Services,
> a General Dynamics Company
>
> MIT Lincoln Laboratory
> Group 34- Intelligence, Test and Evaluation
> 781-981-2839
>
> cutter@ll.mit.edu

Subject: ismember alternative?

From: Rob Henson

Date: 15 Apr, 2004 10:50:24

Message: 4 of 4


"Kenneth Cutter" <cutter@ll.mit.edu> wrote in message
news:Imwfc.159$9m.108@llnews.ll.mit.edu...
> I have a big simulation that uses "ismember" thousands of times in a run.
> I have found that this is taking a significant amount of execution time.
> The function is working on numeric inputs only.
> Can anyone suggest a (possibly) faster-running alternative?

It depends what you data looks like. If it is ordered or has known step
sizes or intervals (e.g. is all integer valued, or is in a range [0 10] with
2 dp accuracy) then you can often get around using ismember by using
indexing instead. If the data is already sorted then you can create a
stripped down version of ismember that doesn't sort the data.

What does your data look like?

Rob Henson
The MathWorks, Inc.

> Thanks
>
> --
> Kenneth Cutter
>
> Advanced Information Engineering Services,
> a General Dynamics Company
>
> MIT Lincoln Laboratory
> Group 34- Intelligence, Test and Evaluation
> 781-981-2839
>
> cutter@ll.mit.edu
>

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us