Main Content

isscalar

Determine whether input is scalar

Description

example

TF= isscalar(A)returns logical1(true) ifAis a scalar. Otherwise, it returns logical0(false). A scalar is a two-dimensional array that has a size of 1-by-1.

Examples

collapse all

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

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

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

TF = isscalar(A(1,2))
TF =logical1

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)
TF =logical1

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)
TF =logical0

Check the dimension ofBusingsize.Bis not a scalar since it has a size of 1-by-13.

sz = size(B)
sz =1×21 13

Input Arguments

collapse all

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

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

HDL Code Generation
Generate Verilog and VHDL code for FPGA and ASIC designs using HDL Coder™.

Introduced before R2006a