import data from text file
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Data Preparation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!