isscalar - Determine whether input is scalar - MATLAB (original) (raw)

Main Content

Determine whether input is scalar

Syntax

Description

`TF` = isscalar([A](#mw%5F7a91a7b3-ae25-4911-a380-411ce5b339e5)) 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.

example

Examples

collapse all

Create a 2-by-2 matrix. Determine whether it is a scalar.

A = [1 2; 3 4]; TF = isscalar(A)

Check whether the element at the first row and second column of the matrix is a scalar.

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.

Input Arguments

collapse all

Input array, specified as a scalar, vector, matrix, or multidimensional array.

Extended Capabilities

expand all

Theisscalar function fully supports tall arrays. For more information, see Tall Arrays.

Version History

Introduced before R2006a