isspace

Marks the characters that are whitespace.

Category: Language Fundamentals > Data Types

Syntax

tf = isspace(A)

Returns a logical array that is true where the character of A is whitespace.

Description

Whitespace includes the space, tab, newline, carriage return, vertical tab and form feed. It is used to split words by hand or to trim text: s(~isspace(s)) removes every blank.

Input arguments

A
Character array. Other classes give all false.

Output arguments

tf
Logical array the same size as A.

Example

Removing blanks

s = sprintf('a b\tc');
isspace(s)
s(~isspace(s))
Output
ans = 1×5 logical array

   0   1   0   1   0
ans = 'abc'

See also

isletter isstrprop strtrim strsplit regexprep