How to read date and time of a file?

4 ビュー (過去 30 日間)
Agustin
Agustin 2017 年 7 月 4 日
コメント済み: Jan 2017 年 7 月 5 日
Hi! I'm working to plot the displacement time series of a point but I need the time info of each file. The date and time is on the title of each file, like for example "2016.07.08-00.01.08-StaL-001910-Imera_1". The first numbers indicate the date and time when the data was taken. How can I read the date and time as vectors from the file name?
Thanks!

採用された回答

Jan
Jan 2017 年 7 月 5 日
How are the names available? Do you have them in a cell string already or do you want to grap them by dir?
If you have the string
C = '2016.07.08-00.01.08-StaL-001910-Imera_1'
D = sscanf(C, '%d.%d.%d-%d.%d.%d', 6)
  2 件のコメント
Agustin
Agustin 2017 年 7 月 5 日
This worked perfectly! I did the following and got the following result:
D = D'
D =
2016 7 8 0 1 8
>>
t = datestr(D)
t =
08-Jul-2016 00:01:08
The result of t is what I was looking for but I want the date and time separate. For example, if I create a structure of the data, I want the date in one column and the time in another. How can I do that? Thank you so much for your help.
Jan
Jan 2017 年 7 月 5 日
Perhaps:
Date = D(1:3);
Time = D(4:5);
What does "date in one column" exactly means? What is "a structure of the data"? Please post a small example.

サインインしてコメントする。

その他の回答 (1 件)

Agustin
Agustin 2017 年 7 月 5 日
I created a structure to have a list of the focusing parameters I need from the data and in those parameters, the filename is stored as a string. Thank you so much for your help! I will try this.

カテゴリ

Help Center および File ExchangeCalendar についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by