Contradictory results in command window with variable class and ischar function?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Nicholas Kavouris
am 3 Nov. 2022
Kommentiert: Stephen23
am 4 Nov. 2022
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 Kommentar
Stephen23
am 4 Nov. 2022
"Contradictory results in command window with variable class and ischar function?"
No.
"How is this possible?"
Akzeptierte Antwort
Bruno Luong
am 3 Nov. 2022
class structure(8).timetotemp
is like
class('structure(8).timetotemp')
which return char.
The correct function syntax call is
class(structure(8).timetotemp)
0 Kommentare
Weitere Antworten (1)
Steven Lord
am 3 Nov. 2022
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 Kommentare
Siehe auch
Kategorien
Mehr zu Data Type Identification finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!