How to create a 3D matrix in Octave
In order to create a X*Y*Z
-sized 3D matrix in Octave, use
A = zeros(X, Y, Z);
For example, to create a 5x6x3
matrix, use
A = zeros(5, 6, 3);
zeros()
initializes the matrix to 0
:
>> A = zeros(5, 6, 3);
>> A
A =
ans(:,:,1) =
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
ans(:,:,2) =
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
ans(:,:,3) =
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0