if a variable has the dimension 1 x 1 is it a matrix, scalar, row or column vector

62 vues (au cours des 30 derniers jours)
If a variable has the dimension 1 x 1 is it a matrix, scalar, row or column vector. I've tried finding a solution in the book but it doesnt really say.
  3 commentaires
John D'Errico
John D'Errico le 6 Sep 2019
Definitely!
Scalars and vectors are all just special cases of a matrix. That is, a vector is a matrix with one row, or one column, depending on the orientation.
A scalar is a vector of length 1. So a scalar is also a 1x1 matrix.
Stephen23
Stephen23 le 6 Sep 2019
One of the things I have always appreciated about MATLAB is how scalars and empty arrays are not special data types: for loops defined over all elements will iterate as many times as the array has elements, as they should. It is easy to test using isscalar or isempty if required, otherwise there is absolutely no reason why a 1x1 vector should be treated any differently than a 1x10 vector.

Connectez-vous pour commenter.

Réponse acceptée

Steven Lord
Steven Lord le 6 Sep 2019
dpb and John are correct that the answer is "all of the above". There are functions you can use to check this (see the "Determine Size, Shape, and Order" section on that page) and each describes the criteria an array needs to satisfy for that array to be considered a matrix / scalar / row vector / column vector.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by