1. Connect two arrays
CAT(DIM,A,B) connects arrays A and B, DIM stands for dimension .
Example:
CAT(2,A,B) can get [A,B]. Horizontal splicing.
CAT(1,A,B) can get [A;B]. Vertical splicing.
CAT(3,A,B) can be understood as 3D space superposition and splicing.
CAT(4,A,B) can be understood as a 4-dimensional space superposition and splicing. The schematic diagram here cannot be given because I can't imagine how to draw it.
It can also be higher dimensional.
2. Connect multiple arrays
B = CAT(DIM,A1,A2,A3,A4,...) means to connect multiple arrays (A1, A2, A3, A4,...) along the dimensional direction.
CAT(DIM,C{:}) or CAT(DIM,C.FIELD) both mean to connect the units of the digital matrix or the structure array. Form a single matrix.
3. Examples
a = magic(3); % 生成3*3的矩阵,矩阵满足横向,纵向,对角线之和都相等。(参考下方图片)
b = pascal(3); % 帕斯卡矩阵:由杨辉三角形表组成的矩阵称为帕斯卡(Pascal)矩阵。(参考下方图片)
c = cat(4,a,b) %产生3×3×1×2的结果
s = {a b};
for i=1:length(s),
siz{i} = size(s{i});
end
sizes = cat(1,siz{:}); %生成一个2乘2的大小向量数组。