フィルターのクリア

Number to datetime from textdata

1 回表示 (過去 30 日間)
Mikkel Ibsen
Mikkel Ibsen 2018 年 3 月 15 日
編集済み: dpb 2018 年 3 月 15 日
Hi
I have this data that comes in a text document like this:
"%20180313123648396"
"%20180313123656586"
"%20180313123657351"
"%20180313123658552"
"%20180313123659316"
I need a way for matlab to read the numbers and then make it into a datetime.
So they would come out like:
13-03-2018 12:36:48
13-03-2018 12:36:57
13-03-2018 12:36:57
13-03-2018 12:36:59
13-03-2018 12:36:59
How do I do that? I know how to remove the % sign, but i cant make a number into a datetime, I've tried to sat the InputFormat to: yyyyMMDDHHMMSS but it cannot read it.
Please help
  1 件のコメント
Greg
Greg 2018 年 3 月 15 日
編集済み: Greg 2018 年 3 月 15 日
Help us first - what have you tried? Post the relevant code.

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

採用された回答

dpb
dpb 2018 年 3 月 15 日
編集済み: dpb 2018 年 3 月 15 日
If I put your exact text in a file then
>> fmt='%{%yyyyMMddHHmmssSSS}D'
fmt =
%{%yyyyMMddHHmmssSSS}D
>> fid=fopen('mikkel.dat');
>> d=textscan(fid,fmt,'collectoutput',1)
d =
cell
[5×1 datetime]
>> fid=fclose(fid);
>> d=d{:}
d =
5×1 datetime array
%20180313123648396
%20180313123656586
%20180313123657351
%20180313123658552
%20180313123659316
>> d.Format='default'
d =
5×1 datetime array
13-Mar-2018 12:36:48
13-Mar-2018 12:36:56
13-Mar-2018 12:36:57
13-Mar-2018 12:36:58
13-Mar-2018 12:36:59
>>

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by