Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

isstring

Determine if input is string array

Syntax

tf = isstring(A)

Description

example

tf = isstring(A) returns 1 (true) if A is a string array. Otherwise, it returns 0 (false).

Examples

collapse all

Create different arrays, and then determine if they are string arrays.

Test a character vector.

chr = 'Mary Jones'
chr = 
'Mary Jones'
tf = isstring(chr)
tf = logical
   0

Character vectors are not strings, so isstring returns 0.

Test a string array. Starting in R2017a, you can create strings using double quotes instead of the string function.

str = ["Smith","Chung","Morales"; ...
       "Sanchez","Peterson","Adams"]
str = 2x3 string array
    "Smith"      "Chung"       "Morales"
    "Sanchez"    "Peterson"    "Adams"  

tf = isstring(str)
tf = logical
   1

str is a string array, so isstring returns 1.

Input Arguments

collapse all

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

Extended Capabilities

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

Introduced in R2016b

Was this topic helpful?