use of short Circuit operator
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi, How can I use short circuit operators(&&) in vector variable?
댓글 수: 0
채택된 답변
Walter Roberson
2012년 10월 15일
You cannot. && can only be used for scalars.
Note that if you are trying to code something like
if vector1 && vector2
then the "if" would be considered true only if all values in "vector1 && vector2" evaluated to true, because that is how "if" behaves on vectors and matrices, as if there was an all() wrapped around everything:
if all(vector1 && vector2)
With some minor thought on the meaning of "&" you can see this would be the same as
if all(all(vector1) && all(vector2))
which could be written more briefly as
if all(vector1) && all(vector2)
which is allowed.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Visualization and Data Export에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!