matsplit

版本 1.3.0.0 (568 字节) 作者: Matthew Eicholtz
Split matrix elements into separate variables.
784.0 次下载
更新时间 2014/11/13

查看许可证

This function takes an array as input and returns each element of the array as a separate output. It is similar in function to deal, but less verbose when dealing with a single matrix.

I created this function because I wanted a one-liner alternative to the following code:
c = num2cell(rect); %rect is a rectangle position vector
[x,y,wid,hei] = c{:};

Now I can simply use:
[x,y,wid,hei] = matsplit(rect);

The number of output arguments does not need to match the number of elements in the input array.

Alternatively, you can split the matrix by row or column using the second input DIM.

Example:
A = [1 2 3 4
1 2 3 4
1 2 3 4];
[B,C] = matsplit(A,1);

returns

B = [1;1;1];
C = [2;2;2];

引用格式

Matthew Eicholtz (2024). matsplit (https://www.mathworks.com/matlabcentral/fileexchange/48439-matsplit), MATLAB Central File Exchange. 检索来源 .

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

Community Treasure Hunt

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

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

Added image.

1.2.0.0

Removed requirement that nargout==numel(A).
Added second (optional) input to split matrix by row or column.

1.1.0.0

Minor changes to description.

1.0.0.0