What is the syntax of `i++` in Matlab
increment, matlab, syntax
Solution
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.
Problem
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`.