Create a 3D matrix
A = zeros(20, 10, 3); %# Creates a 20x10x3 matrix
Add a 3rd dimension to a matrix
B = zeros(4,4);
C = zeros(size(B,1), size(B,2), 4); %# New matrix with B's size, and 3rd dimension of size 4
C(:,:,1) = B; %# Copy the content of B into C's first set of values
zeros is just one way of making a new matrix. Another could be A(1:20,1:10,1:3) = 0
for a 3D matrix. To confirm the size of your matrices you can run: size(A)
which gives 20 10 3
.
There is no explicit bound on the number of dimensions a matrix may have.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…