import data from text file

4 ビュー (過去 30 日間)
Alec Bledsoe
Alec Bledsoe 2022 年 9 月 13 日
編集済み: dpb 2022 年 9 月 14 日
I have a text file of values generated by an elvis data collection board. I am trying to import the values into matlab but I cannot get it organized properly. I am trying to get just the time in seconds (including decimal values) and the voltage (the last value in each line) but it is not coming in correctly. I have tried the importdata and readmatrix without any luck. I would manually enter the data but there is 152000 lines. I have only been able to read the voltage values so far. I have the file as a .csv and a .txt but they both have the same results.
Time Dev1 (NI ELVIS II+)/ai0
9/13/2022 08:25:02.307736 -4.046230E+0
9/13/2022 08:25:02.307836 -4.046230E+0
9/13/2022 08:25:02.307936 -4.045264E+0
9/13/2022 08:25:02.308036 -4.044619E+0
9/13/2022 08:25:02.308136 -4.044941E+0
9/13/2022 08:25:02.308236 -4.044297E+0
9/13/2022 08:25:02.308336 -4.044941E+0
9/13/2022 08:25:02.308436 -4.045908E+0
9/13/2022 08:25:02.308536 -4.045586E+0
9/13/2022 08:25:02.308636 -4.044619E+0
9/13/2022 08:25:02.308736 -4.045586E+0
9/13/2022 08:25:02.308836 -4.044941E+0
9/13/2022 08:25:02.308936 -4.044941E+0
9/13/2022 08:25:02.309036 -4.045264E+0

採用された回答

Walter Roberson
Walter Roberson 2022 年 9 月 13 日
If you readtable() then with that data, it should detect 3 columns, with the first one being datetime() and the second being duration() and the third being data.
Create a new variable that is the Time (datetime) plus the duration; you might want to set as Format for the result.
Now if you take the datetimes minus the first datetime in the variable, then you will get duration relative to the beginning of the table. You can then ask for seconds() of that to get the duration in seconds relative to the beginning of the table.
  3 件のコメント
Walter Roberson
Walter Roberson 2022 年 9 月 14 日
numheaderlies ? 😁
dpb
dpb 2022 年 9 月 14 日
I knew there'd be a typo somewhere, Walter...good catch, thanks!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by