Find myltiple numbers in array

This function returns the indexes of multiple elements in an array.
389 download
Aggiornato 26 set 2010

Visualizza la licenza

multiFind serves a similar purpose as find but when looking for multiple elements in an array of numbers. It returns two arrays of numbers. Each row of the two arrays contains the pair of indexes in which the numbers were found in the two arrays

Input:
array: the array in which you want to find some numbers
nums: the numbers you are looking for inside the array
varargin:
type: type refers to the type of the output. If it gets the value
'index', it returns just the pairs of indexes of the numbers in the
two arrays 'array' and nums respectively. If it gets the value 'bin', it returns
two binary arrays, with 1's where the elements were found in the two arrays.
Default value: 'index'
except: if you want to exclude specific numbers from the search, you
use the except options and declare these numbers

Output:
idx: the indexes of the found numbers in the first array
posIdx: the indexes of the numbers in 'nums' of the numbers that were
also found in 'array'

Example:

im1 = randi(1000, 100, 1) ;
im2 = randi(1000, 100, 1) ;

[ix1, ix2] = multiFind(im1, im2) ;
[ix1, ix2] = multiFind(im1, im2, 'type', 'index') ;
[ix1, ix2] = multiFind(im1, im2, 'type', 'bin') ;
[ix1, ix2] = multiFind(im1, im2, 'except', [1, 3]) ;

Author: Efstratios Gavves
email: efstratios.gavves@gmail.com
website: http://staff.science.uva.nl/~gavves/

Cita come

Stratis Gavves (2025). Find myltiple numbers in array (https://it.mathworks.com/matlabcentral/fileexchange/28849-find-myltiple-numbers-in-array), MATLAB Central File Exchange. Recuperato .

Compatibilità della release di MATLAB
Creato con R2010a
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS Linux
Categorie
Scopri di più su Matrix Indexing in Help Center e MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versione Pubblicato Note della release
1.0.0.0