Why is this string considered length one?

조회 수: 10 (최근 30일)
cypher
cypher 2013년 5월 22일
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
cypher
cypher 2013년 5월 22일
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

댓글을 달려면 로그인하십시오.

채택된 답변

cypher
cypher 2013년 5월 22일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by