简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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