Contradictory results in command window with variable class and ischar function?
조회 수: 2 (최근 30일)
이전 댓글 표시
debugging a script i wrote and came across this? How is this possible?
K>> class structure(8).timetotemp
ans =
'char'
K>> ischar(structure(8).timetotemp)
ans =
logical
0
댓글 수: 1
Stephen23
2022년 11월 4일
"Contradictory results in command window with variable class and ischar function?"
No.
"How is this possible?"
채택된 답변
Bruno Luong
2022년 11월 3일
class structure(8).timetotemp
is like
class('structure(8).timetotemp')
which return char.
The correct function syntax call is
class(structure(8).timetotemp)
댓글 수: 0
추가 답변 (1개)
Steven Lord
2022년 11월 3일
This code, class structure(8).timetotemp, is equivalent to:
class('structure(8).timetotemp')
If you had a variable array named structure whose 8th element had a property or field named timetotemp and you wanted to know the class of that property or field, use the function form of the class function call rather than the command form.
structure(8) = struct('timetotemp', datetime('today'))
class(structure(8).timetotemp)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Identification에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!