Finding whether a value is equal to the value of any array element in MATLAB

Posted by James on Stack Overflow See other posts from Stack Overflow or by James
Published on 2010-03-14T15:11:26Z Indexed on 2010/03/14 15:15 UTC
Read the original article Hit count: 153

Filed under:
|
|

Hi,

Can anyone tell me if there is a way (in MATLAB) to check whether a certain value is equal to any of the values stored within another array?

The way I intend to use it is to check whether an element index in one matrix is equal to the values stored in another array (where the stored values are the indexes of the elements which meet a certain criteria).

So, if the indices of the elements which meet the criteria are stored in the matrix below:

criteriacheck = [3 5 6 8 20];

Going through the main array (called array) & checking if the index matches:

for i = 1:numel(array) if i == 'Any value stored in criteriacheck' ... "Do this" end

Does anyone have an idea of how I might go about this?

Thanks in advance

© Stack Overflow or respective owner

Related posts about matlab

Related posts about element