How to check a number is in a array or not?
2,558 ビュー (過去 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!