What is 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].

I seem to need to know this in order to understand what I'm doing cat.

+3
source share
2 answers
[A,B]

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

[A;B]

- a matrix formed by placing B below A.

Learn also about horzcatand vertcat.

+3
source
[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 in matlab and open ans to see the difference

+3
source

Source: https://habr.com/ru/post/1740488/


All Articles