Additional note: I noticed I have non-date data on the first row.. How do I treat the first row as NaN data?
Need help with datenum function
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Adhi Ariawan
am 29 Nov. 2017
Kommentiert: Star Strider
am 29 Nov. 2017
I'm using Matlab R2015b. I have "date" variable ( 178x1 cell ) inside a struct named "data". It consists of one column with multiple rows that consists of dates in dd/mm/yyyy format. Now I'm trying to convert them into numbers using datenum command,
dates = datenum(data.date, 'dd/mm/yyyy');
but it returns me with error.. What am I doing wrong? I've attached a screenshot of what the data looks like. Thanks in advance.
Akzeptierte Antwort
Star Strider
am 29 Nov. 2017
Note that the first row is the string ‘date’. The datenum function will fail on that, so start with the second row instead.
4 Kommentare
Weitere Antworten (1)
Peter Perkins
am 29 Nov. 2017
If you have R2015b, you will likely be happioer using datetimes rather than datenums:
dates = datetime(data.date(2:end),'Format','dd/mm/yyyy')
You may also want to use a table, rather than a scalar struct, but hard to say without seeing more.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Time Series Objects finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!