How to use multiple equal signs?

조회 수: 19 (최근 30일)
Elvis Somers
Elvis Somers 2017년 3월 22일
댓글: Adam 2017년 3월 22일
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
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개)

Adam
Adam 2017년 3월 22일
a == b && b == c

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by