Is there an equivalent to the '+=' operator in MATLAB?

281 ビュー (過去 30 日間)
Rowan Lawrence
Rowan Lawrence 2019 年 11 月 7 日
編集済み: the cyclist 2019 年 11 月 7 日
Hello,
When I've programmed in C and C++ before I've used the '+=' operator, which is a shorthand way of adding a given value to the current value of a variable without having to restate the original variable on the right-hand side, for example:
x = x + y
can be written as:
x += y
However this doesn't seem to work in MATLAB and produces an incomprehensible error message (at least to me). I looked up an equivalent and found forum posts of people who had migrated from Java (where apparently this is the equivalent of the '++' increment operator in C/C++?). It isn't really important, I'm just wondering if there is any equivalent to the way I have used it above.
Cheers!

採用された回答

the cyclist
the cyclist 2019 年 11 月 7 日
編集済み: the cyclist 2019 年 11 月 7 日
No, MATLAB does not have that syntax.
There is some prior discussion of this issue in this question.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by