a = [1 2 3;
4 5 6;
7 8 9];
b = [10 11 12;
13 14 15;
16 17 18;
];
c = [19 20 21;
22 23 24;
25 26 27;
];
I want to combine the above 2D matrices into a 3D matrix mat
so that I can access them in the following way,
>> mat(:, :, 1)
ans =
[1 2 3
4 5 6
7 8 9]
>> mat(:, :, 2)
ans =
[10 11 12
13 14 15
16 17 18]
>> mat(:,:,3)
ans =
[19 20 21
22 23 24
25 26 27]
I tried the following,
mat = [a, b, c];
But, it actually doesn't work.
So, how can I achieve that?