Help CenterHelp Center
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).
A
1
true
0
false
example
collapse all
Create different arrays, and then determine if they are string scalars.
Test a string scalar.
str = "Mercury"
tf = isStringScalar(str)
tf = logical 1
Test a string array with multiple elements. Since str contains more than one element, isStringScalar returns 0.
str
isStringScalar
str = ["Mercury","Gemini","Apollo"]
str = 1x3 string "Mercury" "Gemini" "Apollo"
tf = logical 0
Test a character vector. Since character vectors are not strings, isStringScalar returns 0.
chr = 'Pluto'
tf = isStringScalar(chr)
Input array, specified as an array of any size and data type.
Introduced in R2017b
cellstr | char | isstrprop | isa | iscellstr | ischar | string | isstring | ismissing
cellstr
char
isstrprop
isa
iscellstr
ischar
string
isstring
ismissing
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office