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!