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

153 ビュー (過去 30 日間)
mohammad
mohammad 2014 年 7 月 29 日
コメント済み: Steven Lord 2022 年 6 月 25 日
i want to know the difference between the matrix and array in terms of the meaning and function , if any one will answer please with an example thanks
  4 件のコメント
dpb
dpb 2014 年 7 月 29 日
An array is any ordered n-dimensional collection.
Star Strider
Star Strider 2014 年 7 月 29 日
MATLAB takes liberties with the definition. See for example the documentation on Cell Arrays.

サインインしてコメントする。

採用された回答

Arun Mathew Iype
Arun Mathew Iype 2014 年 7 月 29 日
編集済み: Jan 2017 年 5 月 30 日
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
  3 件のコメント
Markiian
Markiian 2022 年 6 月 25 日
Thanks a lot!
Steven Lord
Steven Lord 2022 年 6 月 25 日
Another way to explain this is by looking at the help text for the ismatrix function.
help ismatrix
ISMATRIX True if input is a matrix. ISMATRIX(M) returns logical 1 (true) if M is an m-by-n matrix, and logical 0 (false) otherwise. See also ISSCALAR, ISVECTOR, ISROW, ISCOLUMN, ISNUMERIC, ISLOGICAL, ISCHAR, ISEMPTY, SIZE. Documentation for ismatrix doc ismatrix Other functions named ismatrix categorical/ismatrix distributed/ismatrix tall/ismatrix datetime/ismatrix duration/ismatrix
So a 1-by-1 array is a matrix. A 3-by-3 array is also a matrix. But a 2-by-3-by-4 array is not a matrix.
ismatrix(zeros(1, 1))
ans = logical
1
ismatrix(zeros(3, 3))
ans = logical
1
ismatrix(zeros(2, 3, 4))
ans = logical
0

サインインしてコメントする。

その他の回答 (1 件)

Robin Szeto
Robin Szeto 2017 年 5 月 30 日
All MATLAB variables are multidimensional arrays, no matter what type of data. A matrix is a two-dimensional array often used for linear algebra. source: https://www.mathworks.com/help/matlab/learn_matlab/matrices-and-arrays.html
  2 件のコメント
Stephen23
Stephen23 2017 年 5 月 30 日
編集済み: Stephen23 2017 年 5 月 30 日
+1 This is true: all MATLAB array types are N-dimensional, with implicit infinite trailing singleton dimensions, as has been discussed many times before:
"Arrays in MATLAB are N-dimensional, with an infinite number of trailing singleton dimensions."
Markee Foster
Markee Foster 2020 年 4 月 9 日
helpful clarification!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeRubik's Cube についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by