Borrar filtros
Borrar filtros

How to extract date and time that not in datetime format?

2 visualizaciones (últimos 30 días)
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';

Respuesta aceptada

Walter Roberson
Walter Roberson el 12 de Abr. de 2018
dates = cellfun( @(S) datetime(S([1:8, 44:49]), 'InputFormat', 'yyyyMMddHHmmss', 'Format', 'MM/dd/yyyy HH:mm:ss'), FileNamesCell );

Más respuestas (0)

Categorías

Más información sobre Dates and Time en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by