if a variable has the dimension 1 x 1 is it a matrix, scalar, row or column vector
24 次查看(过去 30 天)
显示 更早的评论
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 个评论
John D'Errico
2019-9-6
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
2019-9-6
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.
采纳的回答
Steven Lord
2019-9-6
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.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!