reading text data consisting of a specific format

2 ビュー (過去 30 日間)
Jonathan
Jonathan 2019 年 9 月 26 日
コメント済み: Jonathan 2019 年 10 月 1 日
I have a text file containing data of the form:
201901010000
201901010100
201901010200
201901010300
201901010400
201901010500
201901010600
201901010700
201901010800
201901010900
201901011000
...
The data reflect date and time information. I'm trying to figure out a way to read these data in and then parse to a matrix that reflects year, month, day, hour etc. The latter is simple, I'm just stuck on how to read the data in. I have explored both textscan and fscanf but nothing obvious springs to mind. For example, read first 4 numbers = year, 5-6=month etc. Thank you

採用された回答

Adam Danz
Adam Danz 2019 年 9 月 26 日
編集済み: Adam Danz 2019 年 9 月 30 日
datastr = strsplit(fileread('myTextFile.txt'));
dateMat = datevec(datastr,'yyyymmddHH');
Check that the input format in datevec() describes your datetime format.
  1 件のコメント
Jonathan
Jonathan 2019 年 10 月 1 日
Thank you, this was exactly what I was looking for.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by