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

조회 수: 23 (최근 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
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
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
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개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by