Thursday, February 21, 2008

about logical indexing

Today, M-Lint was telling me that "logical indexing is usually faster than FIND".

I didn't knew what logical indexing means. a short google search and i found this out:

if you want to perform the following operation:

KdP(find( (dP> 1000) & (dP <= 2000) )) = 2;


you can optimize it just by omitting the find command just like this:
KdP( (dP> 1000) & (dP <= 2000) ) = 2;

. Matlab is just capable to handle the "logical indexing" which means the indexes of the vector that match the conditions.

5 comments:

Anonymous said...

Thanks !!

Anonymous said...

Thanks !!

Anonymous said...

You solved my problems!!! I hated the message. Well answered!

Unknown said...

for a long time, I interpreted that message as "if you order your data in a logical manner, you do not need to do a find". Only yesterday did I find out what it means.

Any idea, though, just how much faster it is?

Anonymous said...

You can test with

tic

...

toc