How to switch to the opposite value of a logical type?

154 ビュー (過去 30 日間)
Christopher Wong
Christopher Wong 2020 年 4 月 15 日
回答済み: Walter Roberson 2020 年 4 月 15 日
Hello all, I'm wondering if theres some shorthand syntax to switch the current value of a logical to the opposite value. That is, if a = true, then a = false, otherwise a = true.
Yes, I realize I just described the obvious syntax: if (a), a = false; else, a = true; end, but I'm just wondering if MATLAB's got some function available that allows for more concise scripting.

採用された回答

Walter Roberson
Walter Roberson 2020 年 4 月 15 日
a = ~a;

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by