Shai Zarzewski
Shai Zarzewski

Reputation: 1698

how can I do a *= operator in matlab

I'm trying to do in Matlab: X = X*-1;

this syntax is a bit annoying, is there a way to do this some other way (like in c++ : x*=-1)

Thank you

Upvotes: 2

Views: 4004

Answers (2)

A. Donda
A. Donda

Reputation: 8477

There is another way! ;-)

X = -X;

Seriously though, I think it's just a matter of habit. There's nothing inherently wrong with that syntax, you are just used to do it differently.

Upvotes: 4

kamjagin
kamjagin

Reputation: 3654

Unfortunately there are no increment and compound assignment operators in Matlab. I also remember reading posts by employees at Mathworks saying that they don't intend to add such operators to Matlab.

Steve Lord's reply to the following question illustrates the difficulties involved (way down, reply nr 10 or so): http://www.mathworks.com/matlabcentral/newsreader/view_thread/107451

Upvotes: 5

Related Questions