MATLAB: Datetime error when going from r2017a to r2016a

datetimeMATLABversion switching

The code is generating an error when using the datetime fuction:
Error using datetime/double (line 1475)
Undefined function 'double' for input arguments of type 'datetime'. To convert from datetimes to numeric, first subtract off
a datetime origin, then convert to numeric using the SECONDS, MINUTES, HOURS, DAYS, or YEARS functions.
This odd because my code works perfectly in r2017a on Windows but I get the error in r2016a on Linux. I have put the code below:
%remove all rows not containing 'OPC.Temperature.BottomTemperature' in
%column 2
temp_string = 'OPC.Temperature.BottomTemperature';
temp_comp = strcmp(data_temp(:,2),temp_string);
temp_comp = ~temp_comp;
data_temp(temp_comp,:) = [];
%remove extra information from columns 3 & 4 from data_temp
data_temp(:,(2:4)) = [];
%convert data_temp cell array to table
data_temp = array2table(data_temp,'VariableNames',{'TimeStamp' 'Temperature'});
%convert timestamp string to datetime
data_temp.TimeStamp = datetime(data_temp.TimeStamp,'InputFormat','yyyy-MM-dd HH:mm:ss.SSS');
%convert temperature string to double precision value
data_temp.Temperature = str2double(data_temp.Temperature);
%remove rows from data_table with temperature below 30C and above 1300C
delete_30 = data_temp.Temperature <30;
data_temp(delete_30,:) = [];
delete_1300 = data_temp.Temperature >1300;
data_temp(delete_1300,:) = [];
%plot temperature vs timestamp
subplot(2,2,1); scatter(data_temp.TimeStamp, data_temp.Temperature); title('Temperature');
The whole code reads a text file using textscan and puts the data into the data_temp variable.
Any thoughts???

Best Answer

The ability to use a datetime as an axis on a scatter plot or a plot was not added until R2016b.
For earlier releases you can use datenum() on the datetime, and then be sure to datetick() with an appropriate axis format.