Matlab swap elements like in Python

I am new to Matlab. In Python, you can easily change elements.

x, y = 5, 10

x, y = y, x

Is there something similar in Matlab (or in Octave / Scilab)? Otherwise, what is the best way to replace elements without using a temporary variable?

+4
source share
1 answer

deal is the feature you are looking for.

[y,x] = deal(x,y);

Example:

x=5; y=10;
[y,x] = deal(x,y)

y =
     5

x =    
    10
+5
source

Source: https://habr.com/ru/post/1696173/


All Articles