How to check a number is in a array or not?
조회 수: 2,480(최근 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
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.
추가 답변(1개)
참고 항목
범주
Find more on Multidimensional Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!