How to check a number is in a array or not?
2,483 次查看(过去 30 天)
显示 更早的评论
a=[8 9 6 5 3], I want to know 5 is there or not.
0 个评论
采纳的回答
Guillaume
2017-8-29
ismember(5, a)
2 个评论
Putri Basenda Tarigan
2020-11-16
Excuse me Sir,
For the same problem, if we don't know that the number is 5, how to code to get that the number is 5?
Matthew Coile
2023-2-17
Putri, you can just as easily use a variable. That is, ismember(x,a) would work as well, where the value of x is assigned earlier in the script.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!