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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by