swapVars(x,y)

版本 1.1.0.0 (1.2 KB) 作者: Sugato
Swap two variables (of same type and size) as tuples (used in Python).
15.0 次下载
更新时间 2017/8/12

查看许可证

Function Description:
This function swaps the a pair of input variables, provided they are of
the same size (shape).

AUTHOR: Sugato Ray | Created on: 12-AUG-2017 | ray.sugato[at]gmail.com

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PLEASE ACKNOWLEDGE THE AUTHOR IF YOU USE THIS CODE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

NOTE: X = y and Y = x. This function enables you to write the following
expression (equivalent to Tuples concept in Python).

[X,Y] = swapVars(X,Y);

EXAMPLE:
[X,Y] = swapVars(X,Y);

Check the following steps for step-by-step clarity and fact-checking:
xx = ones(3,3)
yy = zeros(3,3)
[xx,yy] = swapVars(xx,yy)
Note: This function works similar to: 'deal' function
[yy,xx] = deal(xx,yy)

引用格式

Sugato (2025). swapVars(x,y) (https://www.mathworks.com/matlabcentral/fileexchange/64090-swapvars-x-y), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2016a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Python Data Types in MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.1.0.0

Updated function description.
Updated function description.

1.0.0.0

Updated the documentation.