简体   繁体   English

MatLab中[A,B]和[A; B]之间有什么区别?

[英]What's the difference between [A,B] and [A;B] in MatLab?

%   CAT(2,A,B) is the same as [A,B].
%   CAT(1,A,B) is the same as [A;B].

Seems I need to know this to understand what cat does. 似乎我需要知道这一点,以了解cat作用。

[A,B]

is a matrix formed by placing B to the right of A, while 是通过将B放在A的右边而形成的矩阵

[A;B]

is a matrix formed by placing B below A. 是将B置于A下方形成的矩阵。

Learn also about horzcat and vertcat . 还要了解horzcatvertcat

[A, B] does col cat
[A; B] does row cat

eg: 例如:

x = [1, 2, 3];
y = [7, 8, 9];

[x, y] == > [1, 2, 3, 7, 8, 9]

becomes a 1x6 array




[x; y] == > [1, 2, 3]
            [7, 8, 9]

becomes a 2x3 array

Just try it in Matlab and open ans to see the difference 只需在Matlab中尝试并打开ans即可看出差异

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM