Why is this string considered length one?

8 visualizaciones (últimos 30 días)
cypher
cypher el 22 de Mayo de 2013
Why is '15' a string of length one?
>> datestamp = '1991-6-15'
datestamp =
1991-6-15
>> a = textscan(datestamp,'%4s %2s %2s','Delimiter','-');
>> length(a{3})
ans =
1
>> a{3}
ans =
'15'
I'm trying to get the length of the string. Sometimes letters will be used, so converting to numbers is not an option.
Why is '15' a string of length one?
  1 comentario
cypher
cypher el 22 de Mayo de 2013
ANSWER:
a{3} is a cell array of one cell
a{3}{1} is a cell of one string
length( a{3}{1} ) is 2

Iniciar sesión para comentar.

Respuesta aceptada

cypher
cypher el 22 de Mayo de 2013
ANSWER:
a{3} is a cell array of one cell
a{3}{1} is a cell of one string
length( a{3}{1} ) is 2

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by