필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Brandon Leonard
Brandon Leonard 2018년 4월 12일
답변: Walter Roberson 2018년 4월 12일
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';

채택된 답변

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by