필터 지우기
필터 지우기

what's the difference between | and || in matlab??

조회 수: 388 (최근 30일)
maha ismail
maha ismail 2014년 12월 10일
편집: Stephen23 2024년 3월 19일
what's the difference between | and || in matlab??

채택된 답변

matt dash
matt dash 2014년 12월 10일
이동: Stephen23 2024년 3월 19일
Clarification: for short circuit "and" no tests are evaluated after the first "false". For short circuit "or" no tests are evaluated after the first true.

추가 답변 (1개)

Sean de Wolski
Sean de Wolski 2014년 12월 10일
편집: Sean de Wolski 2014년 12월 10일
| applies to each element in the array, || applies to a scalar condition:
[1 0 1] | [ 0 0 1]
v.
[1 0 1] || [ 0 0 1]
  댓글 수: 1
Stephen23
Stephen23 2024년 3월 19일
편집: Stephen23 2024년 3월 19일
It is unclear to me what those code examples are supposed to clarify:
[1 0 1] | [0 0 1]
ans = 1×3 logical array
1 0 1
[1 0 1] || [0 0 1]
Operands to the logical AND (&&) and OR (||) operators must be convertible to logical scalar values. Use the ANY or ALL functions to reduce operands to logical scalar values.

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

카테고리

Help CenterFile Exchange에서 Write Unit Tests에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by