0

I built a cell array that contains non-string elements, say, vectors containing numbers.

How can I search if a vector exits in this cell array? Since the elements are not strings, I cannot use ismember() function.

Concretely, if I had a cell array like

a = {[1 2], [2 3], [3 4], [4 5]}

how can I find out if [2 3] is in this cell array?

1
  • I do not want to use for to iterate the cell array. Commented Jun 4, 2013 at 14:13

2 Answers 2

2

I think this should work:

find(ismember(cell2mat(a'),[2 3],'rows'));

or if you don't need the location:

any(ismember(cell2mat(a'),[2 3],'rows'));

Good luck =)

Sign up to request clarification or add additional context in comments.

Comments

1

You can try this :

ismember(num2str([2 3]), cellfun(@num2str, a, 'UniformOutput', false))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.