Documentation

isspace

Determine which character array elements are space characters

Syntax

TF = isspace(A)

Description

example

TF = isspace(A)returns a logical arrayTF. IfAis a character array, the elements ofTFare logical1(true) where corresponding elements ofAare space characters, and logical0(false) elsewhere.isspacerecognizes all Unicode®whitespace characters.

IfAis not a character array, thenisspacereturns logical0(false).

Examples

collapse all

Create different arrays, and then determine which elements are space characters.

chr ='123 Main St.'
chr = '123 Main St.'
TF = isspace(chr)
TF =1x12 logical array0 0 0 1 0 0 0 0 1 0 0 0

Starting in R2016b, you can convert character arrays to strings using thestringfunction. Convertchrto a string, and test it. The input argument is not a character array, soisspacereturns0.

str = string(chr)
str = "123 Main St."
TF = isspace(str)
TF =logical0

Input Arguments

collapse all

Input array, specified as a scalar, vector, matrix, or multidimensional array.Acan be any data type.

Tips

  • To find space characters within elements of a string array, use theisstrpropfunction.

  • To find all characters for whichisspacereturns logical1, use the code below. Then look up the returned decimal codes in a Unicode reference, such as theList ofUnicodecharacters.

    find(isspace(char(1):char(intmax('uint16'))))

Extended Capabilities

Introduced before R2006a

Was this topic helpful?