converting a date into a num
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a structure with 2 columns. When i click on a struction icon i see my dates (Time): dd-mmm-yyy HH:MM:SS (like in a pic above: 01-Jan-2016 00:00:00 ). When i click my dates (Time) of the same structure from the Workspace i get results already converted into a num (doubble). The problem is when i type str(myStructure.Time) i am getting: '08-Apr-2685' (This is the last value). has anyone an idea why is that ?
0 Kommentare
Antworten (2)
KSSV
am 12 Dez. 2021
You can convert dates which are in datetime class using the function datenum.
0 Kommentare
Star Strider
am 12 Dez. 2021
I have no idea what those date numbers are, since they are not MATLAB date numbers, and attempting to convert them as 'excel' or 'posix' fails completely.
Try using a bit of linear algebra to convert them to MATLAB datenum numbers, then convert them to datetime arrays —
dn = datenum([2015 12 31 22 30 00; 2015 12 31 22 40 00]); % Necessary
B = [[63067800; 63068400] ones(2,1)] \ dn; % Necessary (Mapping Vector)
PivotYear = datetime(B(2), 'ConvertFrom','datenum') % Simply Out Of Curiosity
dnv = datetime([[63067800; 63068400; 63069000; 63069600; 63070200; 63070800; 63071400; 63072000] ones(8,1)] * B, 'ConvertFrom','datenum')
Copying them from the Command Window — or better yet, saving them to a variable as a column vector — and then using this approach will likely convert all of them successfully. (It would be nice to know what they are and how to convert them if the encoding is known.)
.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Dates and Time 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!