How to check a number is in a array or not?
조회 수: 2,484 (최근 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!