How to check a number is in a array or not?
2.484 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Arnab Pal
am 29 Aug. 2017
Kommentiert: Matthew Coile
am 17 Feb. 2023
a=[8 9 6 5 3], I want to know 5 is there or not.
0 Kommentare
Akzeptierte Antwort
Guillaume
am 29 Aug. 2017
ismember(5, a)
2 Kommentare
Putri Basenda Tarigan
am 16 Nov. 2020
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
am 17 Feb. 2023
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.
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!