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.


Determine if input is string array with one element


tf = isStringScalar(A)



tf = isStringScalar(A) returns 1 (true) if A is a string array and A has only one element. Otherwise, it returns 0 (false).


collapse all

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

Test a string scalar.

str = "Mercury"
str = 
tf = isStringScalar(str)
tf = logical

Test a string array with multiple elements. Since str contains more than one element, isStringScalar returns 0.

str = ["Mercury","Gemini","Apollo"]
str = 1x3 string array
    "Mercury"    "Gemini"    "Apollo"

tf = isStringScalar(str)
tf = logical

Test a character vector. Since character vectors are not strings, isStringScalar returns 0.

chr = 'Pluto'
chr = 
tf = isStringScalar(chr)
tf = logical

Input Arguments

collapse all

Input array, specified as an array of any size and data type.

Introduced in R2017b