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

22 次查看(过去 30 天)
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.

采纳的回答

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

更多回答(1 个)

Jan
Jan 2021-9-21

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by