A question about matrix manipulation

Posted by appi on Stack Overflow See other posts from Stack Overflow or by appi
Published on 2011-01-14T10:00:02Z Indexed on 2011/01/15 5:53 UTC
Read the original article Hit count: 178

Filed under:
|
|
|
|

Given a 1*N matrix or an array, how do I find the first 4 elements which have the same value and then store the index for those elements?

PS: I'm just curious. What if we want to find the first 4 elements whose value differences are within a certain range, say below 2? For example, M=[10,15,14.5,9,15.1,8.5,15.5,9.5], the elements I'm looking for will be 15,14.5,15.1,15.5 and the indices will be 2,3,5,7.

© Stack Overflow or respective owner

Related posts about arrays

Related posts about algorithm