# Math Help - MATLAB: The cat command

1. ## MATLAB: The cat command

Hi guys

Say I have two 2x2 matrices A and B. If I use the command

Code:
c=cat(3,a,b)
then c(:,:,1) is A and c(:,:,2) is B. Now, if I use c=cat(2,a,b) I get a rowe, and if I use c=cat(1,a,b) I get a 2x2 matrix. What is the logic behind the last two commands?

CB

3. Originally Posted by CaptainBlack

CB
I found http://www.mathhelpforum.com/math-he...t-command.html, but why does it add the matrices vertically when using the first dimension and horizontally with the second dimension? They do now explain that.

Is it just a convention?

4. Originally Posted by Niles_M
I found http://www.mathhelpforum.com/math-he...t-command.html, but why does it add the matrices vertically when using the first dimension and horizontally with the second dimension? They do now explain that.

Is it just a convention?
It is not a convention, the first argument defines the sense of the concatenation (as per the help files)

CB

5. Originally Posted by CaptainBlack
It is not a convention, the first argument defines the sense of the concatenation (as per the help files)

CB
I get it, thanks!