Determine whether input is scalar
TF = isscalar(A)
example
TF = isscalar(A) returns logical 1 (true) if A is a scalar. Otherwise, it returns logical 0 (false). A scalar is a two-dimensional array that has a size of 1-by-1.
TF
A
1
true
0
false
collapse all
Create a 2-by-2 matrix. Determine whether it is a scalar.
A = [1 2; 3 4]; TF = isscalar(A)
TF = logical 0
Check whether the element at the first row and second column of the matrix is a scalar.
TF = isscalar(A(1,2))
TF = logical 1
Create a string scalar by enclosing a piece of text in double quotes. Determine whether it is a scalar.
A = "Hello, World!"; TF = isscalar(A)
Now create a character vector by enclosing a piece of text in single quotes. Determine whether it is a scalar.
B = 'Hello, World!'; TF = isscalar(B)
Check the dimension of B using size. B is not a scalar since it has a size of 1-by-13.
B
size
sz = size(B)
sz = 1×2 1 13
Input array, specified as a scalar, vector, matrix, or multidimensional array.
This function fully supports tall arrays. For more information, see Tall Arrays.
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
iscolumn | ismatrix | isrow | isStringScalar | isvector | size
iscolumn
ismatrix
isrow
isStringScalar
isvector
You have a modified version of this example. Do you want to open this example with your edits?