MATLAB: How to extract date and time that not in datetime format

time series

File name example
20160914_565w081_Laurel_Washingtondc_jb_jr_161451_001.mat
20160914 date 161451 time
The position of the date and time in the file name will be the same for all files. The file name data is a string stored in a cell
I need to create a time series (e.g. ts = timeseries(data,time) creates the time-series object using the specified data and time.) using the date and time from the file name as the ts.TimeInfo.StartDate
How do I extract the date and time from the file name to appear in the format of the the StartDate property.
ts.TimeInfo.StartDate = '10/27/2005 07:05:36';

Best Answer

dates = cellfun( @(S) datetime(S([1:8, 44:49]), 'InputFormat', 'yyyyMMddHHmmss', 'Format', 'MM/dd/yyyy HH:mm:ss'), FileNamesCell );