How to use multiple equal signs?
조회 수: 19 (최근 30일)
이전 댓글 표시
I want to compare three values to each other, like this
a == b == c
But if I try this out with
5 == 5 == 5
It yields FALSE (0) instead of TRUE (1), while it should yield TRUE (1) if a is equal to b and equal to c like 5 is equal to 5 and equal to 5.
Any ideas on how I could fix this?
댓글 수: 1
Adam
2017년 3월 22일
a == b == c
does not work in Matlab because the first part evaluates to give a boolean which is then tested against the final value which will (usually) return false.
답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!