Fix for " The input to DATENUM was not an array of strings."
Show older comments
I am attempting to use datenum on my table (one column, first column) of dates to convert it into a separate variable of just a series of numbers
dataset = readtable('equity_dataset_30.csv');
data = dataset(:,2:31);
date = dataset(:,1);
date_num = datenum(date, 'yyyy-mm-dd');
This last line keeps returning the error: " The input to DATENUM was not an array of strings."
Could someone show what I'm missing here?
Accepted Answer
More Answers (1)
Massimo Zanetti
on 7 Oct 2016
3 votes
Most probably your variable "date" is not an array of strings.
7 Comments
NN
on 25 Oct 2020
kindly see the below code .i also get the same error.kindly advice
%reading date
Data=readtable('2019_SysLoad.xlsx');
save 2019_SysLoad.mat Data
testdates=Data((5834:end),1)};
testdates1=datenum(testdates1,'mm-dd-yyyy');
Walter Roberson
on 25 Oct 2020
testdates = Data{5834:end,1)};
NN
on 25 Oct 2020
thank you .But it gives the following error
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for
mismatched delimiters.
Walter Roberson
on 25 Oct 2020
testdates = Data{5834:end,1};
NN
on 26 Oct 2020
thank you .It worked.
But i am getting spike like output when i plot datenum and forecasted output.Doesnt look lik wave form .
Kindly advice

Walter Roberson
on 26 Oct 2020
I do not see any obvious problem with the plot. It looks to me like what you would expect for a plot displayed with an unfortunate aspect ratio. Try zooming it.
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!