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

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개)

카테고리

도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2017년 3월 22일

댓글:

2017년 3월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by