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 CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by