multidimensional array matlab

Get Matlab Help Now..!


An array possessing more than two dimensions is called a multidimensional array in MATLAB. Multidimensional arrays in MATLAB are the extension of the normal two-dimensional matrix.

Generally to generate a multidimensional array, user should create a two-dimensional array and extend it.

This is further explained with the following example:

a = [7 9 5; 6 1 9; 4 3 2]

MATLAB will compile the above statement and return the following result −

a =

7 9 5

6 1 9

4 3 2

The array a is a 3-by-3 array; a third dimension can be added to a, by providing the values like −

a(:, :, 2)= [ 1 2 3; 4 5 6; 7 8 9]

MATLAB will compile the above statement and return the result in this form −

a =

ans(:,:,1) =

0 0 0

0 0 0

0 0 0

ans(:,:,2) =

1 2 3

4 5 6

7 8 9

Multidimensional arrays can be created using the ones(), zeros() or the rand() functions.

For example,

b = rand(4,3,2)

MATLAB will execute the above statement in this way −

b(:,:,1) =

0.0344 0.7952 0.6463

0.4387 0.1869 0.7094

0.3816 0.4898 0.7547

0.7655 0.4456 0.2760

b(:,:,2) =

0.6797 0.4984 0.2238

0.6551 0.9597 0.7513

0.1626 0.3404 0.2551

0.1190 0.5853 0.5060

The cat() function can be to build multidimensional arrays. It joins a list of arrays along a specified dimension −

Syntax for the cat() function is −

B = cat(dim, A1, A2...)

Where,

B is the new array created

A1, A2, ... are the arrays to be concatenated in MATLAB

dim is the dimension along which user want to concatenate the arrays


CODES BY EXPERTS




BEST CHAT SUPPORT




DELIVERED IN TIME