Is there a shortcut statement that would do what C code i++ would do? (that is to increase i by 1)?
Of course i do not mean the obvious i = i + 1.
No, you cannot do this in Matlab. To increment a variable, you must use i = i + 1;.
Edit - If you were really desperate for something like this, you could define a function that looked like
function increment(x)
evalin('caller', sprintf('%s = %s + 1;', x, x));
end
and call it like this
>> x = 1;
>> increment x;
>> x
x =
2
however this would be (a) confusing and (b) slow.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With