开发者

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.


[A,B]

is a matrix formed by placing B to the right of A, while

[A;B]

is a matrix formed by placing B below A.

Learn also about horzcat and vertcat.


[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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜