Multidimensional array search cell

1 view (last 30 days)
Sharna
Sharna on 8 Oct 2014
Answered: Guillaume on 8 Oct 2014
Hi I have a function where I need to search a multidimensional array to see if it matches a 1x2 matrix.
For example I have pcandidate = [1,1] CLOSED{j} where j is the number of 2x1 matrixes in the feature.
I want to search to make sure from 1:j that none contain the candidate. The list gets up to 2000 so i was trying to achieve something more efficient then looping

Answers (1)

Guillaume
Guillaume on 8 Oct 2014
It's not very clear what the structure and type of your data is (You talk about matrices but then use the {} notation which is for cell array and the dimension of your data jumps from 1x2 to 2x1). In any case, the function you want is ismember:
pcandidate = [1 1];
closed = [1 5
1 1
3 4];
ismember(pcandidate, closed, 'rows') %return true
closed = [1 5
2 2
3 4];
ismember(pcandidate, closed, 'rows') %return false

Community Treasure Hunt

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

Start Hunting!