Skip to main content

5.3) Multi-Dimensional Arrays


2D arrays can be extended into 3D by hand, using indexing. For example:

[matlab]
>> a=rand(3,3);
[/matlab]

"a" is a 3x3 array. To make it into a 3x3x2 array, we can add a third dimension.

[matlab]
>> a(:,:,2)=rand(3,3)
a(:,:,1) =
0.4733 0.5853 0.2858
0.3517 0.5497 0.7572
0.8308 0.9172 0.7537
a(:,:,2) =
0.3804 0.0540 0.9340
0.5678 0.5308 0.1299
0.0759 0.7792 0.5688
[/matlab]