MATLAB Answers


How do i create a 3d matrix?

Asked by Nicky
on 16 May 2013

I have 26 .dat files and 26 .mat files with both the same data. Each file contains a matrix with 32 rows and 32 columns, so 32x32. How do I create a new file with a 3d matrix, with the files in the 3rd dimension, 32x32x26?



No products are associated with this question.

1 Answer

Answer by Walter Roberson
on 16 May 2013
 Accepted answer

YourMatrix = zeros(32, 32, 26);
for K = 1 : 26
   YourMatrix(:,:,K) = input data for this matrix


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!