Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

syntax

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.

like image 400
Gtker Avatar asked Dec 06 '25 06:12

Gtker


2 Answers

[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.

like image 110
High Performance Mark Avatar answered Dec 08 '25 21:12

High Performance Mark


[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

like image 23
Pyrolistical Avatar answered Dec 08 '25 21:12

Pyrolistical