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

时间:2010-04-09 16:58:31

标签: matlab syntax

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

似乎我需要知道这一点,以了解cat的作用。

2 个答案:

答案 0 :(得分:3)

[A,B]

是通过将B放在A的右边而形成的矩阵,而

[A;B]

是通过将B置于A下而形成的矩阵。

还要了解horzcatvertcat

答案 1 :(得分:3)

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

例如:

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

只需在Matlab中尝试并打开ans即可看到差异