Opening the book…
Sometimes a program needs to check what kind of text it has, or what kinds of characters appear inside the text. The functions isstring, ischar, and isStringScalar are used for this purpose.
|
Function |
Returns true when... |
|
isstring(x) |
x is a string array. |
|
isStringScalar(x) |
x is a single string scalar. |
|
ischar(x) |
x is a character vector or character array. |
Checking Individual Character Properties
The function isstrprop checks each character in a character vector and reports whether that character belongs to a category such as alphabetic, digit, lowercase, uppercase, or whitespace.
The result is a logical array. Each position in the result corresponds to one character in the original text. A 1 means true, and a 0 means false.
The following table lists the isstrprop categories and their meaning.
|
Category |
Meaning |
|
'alpha' |
Alphabetic letters. |
|
'alphanum' |
Letters or digits. |
|
'digit' |
Numeric digits such as 0, 1, 2, ..., 9. |
|
'lower' |
Lowercase letters. |
|
'upper' |
Uppercase letters. |
|
'wspace' |
Whitespace, such as spaces, tabs, and newline characters. |
Here are a few other property functions and what they do:
|
Function |
What it does |
| isletter | Checks for alphabetic letters. |
| isspace | Check for whitespace characters |
| iskeyword | Checks whether the input is a reserved MATLAB keyword, such as for, if, or end. |
This page titled 7.8: Checking Text Types and Properties was last modified on Tue, 30 Jun 2026 02:11:54 GMT and is shared under a CC BY-NC-SA license and was authored, remixed, and/or curated by Zara Noroozi.
The book could not be loaded just now.