# what is the difference between matrix and array in the meaning and functions?

798 views (last 30 days)

Show older comments

### Accepted Answer

Arun Mathew Iype
on 29 Jul 2014

Edited: Jan
on 30 May 2017

I agree with what dpb said above. Here is the example which will help you visualize.

Matrix

mat_A= [1 2 3; 3 4 5; 6 7 8]

Conventionally this is shown in 2 dimenstions (2D) as:

Mat_A =

1 2 3

3 4 5

6 7 8

Arrays : May be of various dimensions. The above is a 2D array or matrix. A 1D array is called a vector. arr_1D = [1 2 3 4 5 6 7 8 9] We can also have 3D, as well as, ND arrays. In case of a 3D array, imagine a Rubik’s cube with each cell having a value inside it.

Here is and example using MATLAB "rand" function >> Arr_3D = rand(2,2,2)

Arr_3D(:,:,1) =

0.8147 0.1270

0.9058 0.9134

Arr_3D(:,:,2) =

0.6324 0.2785

0.0975 0.5469

### More Answers (1)

Robin Szeto
on 30 May 2017

##### 2 Comments

### See Also

### Categories

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!