How to convert to datenumber from two cell values
Show older comments
date = cell2mat(tmp{1}(1))
time = cell2mat(tmp{1}(2))
dt = datenum([date time], 'dd:mm:yyyy HH:MM:SS')
Error using datenum (line 181)
DATENUM failed.
Caused by:
Error using dtstr2dtnummx
Failed to convert from text to date number.
What exactly am i doing wrong here?
Thanks in advance
5 Comments
Michael Madelaire
on 15 Feb 2018
Can you provide the content of "tmp"? Just an example.
You forgot to tell us the contents of date and time. What is the contents of
tmp{1}{1}, tmp{1}{2}
? Maybe you forgot the space character at the center?
Duncan Wright
on 15 Feb 2018
Jos (10584)
on 15 Feb 2018
As Jan already hinted at, add a space between date and time
str = [date ' ' time]
datum(str, 'dd:mm:yyyy HH:MM:SS')
What exactly is a "cell structure"? The explanation is not clear:
tmp{1}(1) = 26:05:2017
This is no valid Matlab syntax, therefore the readers have to guess, what it exactly means. Maybe it is a string object:
tmp{1}(1) = "26:05:2017"
Or a cell string:
tmp{1}(1) = {'26:05:2017'}
Please do not let us guess the details. I could post some code and test it, if you show us some valid Matlab code to create the inputs.
Are you sure that the date is written with colons? This is rather unusual.
Accepted Answer
More Answers (0)
Categories
Find more on Time Series Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!