I need a function to identify if a number is part of a vector or matrix.

20 views (last 30 days)
I don't need to know the number or position, I just need to know if a number belongs to a vector or matrix.I use the ismember function, but it is very slow when I repeat this many times, I would like an alternative.
The only consideration is that it has to be a function or quick code.

Accepted Answer

Stephen23
Stephen23 on 21 Sep 2021
Where M is your matrix and N is your scalar number:
any(N==M(:))

More Answers (1)

Jan
Jan on 21 Sep 2021

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!