Using OR between elements in vector or antithesis of any(x)

조회 수: 3 (최근 30일)
Eric Junaeus
Eric Junaeus 2021년 3월 1일
댓글: Stephen23 2021년 3월 2일
Is there a way to use an or command such as | between elements in a vector?
Alternatively:
Rather than use any(x) is there an antithetical command that returns true if any element of the vectorx is zero?
  댓글 수: 1
Stephen23
Stephen23 2021년 3월 2일
"is there an antithetical command that returns true if any element of the vectorx is zero?"
~all(x)
will be simpler and more efficient than anything else.

댓글을 달려면 로그인하십시오.

답변 (1개)

Star Strider
Star Strider 2021년 3월 1일
Not certain what you wnat.
Try these (the any call is there for comparison only):
x = randi([-5 5], 1, 10);
TF1 = any(x == 0);
TF2 = find(x==0)>0;
There may be other options as well.
  댓글 수: 2
Eric Junaeus
Eric Junaeus 2021년 3월 1일
Thanks for the reply!
I tried to make a while loop that would search for any element that's equal to zero in my vector.
It seemed to work with the any command you posted.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by