To Find one element in a matrix or a Vector

4 visualizzazioni (ultimi 30 giorni)
How can I know whether 0 is an element of a Vector or a Matrix
Thank you

Risposta accettata

Jan
Jan il 21 Mar 2018
Modificato: Jan il 21 Mar 2018
containsZero = ~all(V(:))
This avoids to create the temporary array V(:)==0 and for large arrays this should be a measurable advantage.

Più risposte (1)

Stephen23
Stephen23 il 21 Mar 2018
any(V(:)==0)

Categorie

Scopri di più su Language Fundamentals in Help Center e File Exchange

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by