The size () function in Matlab is used to obtain the number of rows and columns in the matrix. This article introduces the usage and basic examples of the size () function in Matlab, for more information about the coders, see this article. The size () function in Matlab is used to obtain the number of rows and columns in the matrix.
(1) s = size (),
If there is only one output parameter, a row vector is returned. When the first element of the row vector is the number of rows in the matrix, the second element is the number of columns in the matrix.
(2) [r, c] = size (),
When there are two output parameters, the size function returns the number of rows in the Matrix to the first output variable r, and returns the number of columns in the Matrix to the second output variable c.
(3) size (A, n) if n is added to the input parameter of the size function and 1 or 2 is assigned to n, size returns the number of rows or columns in the matrix. Where r = size (A, 1) the number of rows returned by the statement, and c = size (A, 2) the number of columns returned by the statement.
In addition, length () = max (size ()).
Summary of size () in Matlab:
For matrix
Number of rows in size (A, 1) matrix
Number of columns in size (A, 2) matrix
[M, n] = size (A), m indicates the number of rows in matrix A, and n indicates the number of columns in matrix.