To Find one element in a matrix or a Vector

2 views (last 30 days)
How can I know whether 0 is an element of a Vector or a Matrix
Thank you

Accepted Answer

Jan
Jan on 21 Mar 2018
Edited: Jan on 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.

More Answers (1)

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

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!