フィルターのクリア

importdata not reading date and time columns

1 回表示 (過去 30 日間)
Ben Keshet
Ben Keshet 2018 年 12 月 25 日
コメント済み: Walter Roberson 2018 年 12 月 27 日
I need to read a text file arranged in columns, using Matlab R2012a, and eventually have it as a matrix so I can plot the numeric data. I have tried multiple ways, eventually importdata commands brings me pretty to close to what I need.
Problem is that the first two columns which are date and time are simply ignored and not read.
THis is about how my text file looks like.
2018-12-24 08:16:10.338 900 0 7550.000 4.846 -113.000 0.001 7.18e-09 4.65e-10 8.24e-12
2018-12-24 08:16:10.588 901.296 0 7550.000 4.856 -113.000 0.001 7.18e-09 4.65e-10 8.25e-12
2018-12-24 08:16:10.838 808.345 0 7550.000 4.846 -113.000 0.001 7.18e-09 4.65e-10 8.78e-13
2018-12-24 08:16:11.089 930.345 0 7550.000 4.846 -113.000 0.001 7.18e-09 4.65e-10 5.67e-13
2018-12-24 08:16:11.339 1000.794 0 7550.000 4.846 -113.000 0.001 7.18e-09 4.65e-10 8.24e-12
My code:
delimiterIn = ' ';
T=importdata('file.txt',delimiterIn);
The T.data table starts with the 3rd columns only.
Appreciate your help.

採用された回答

ahmed nebli
ahmed nebli 2018 年 12 月 25 日
編集済み: madhan ravi 2018 年 12 月 25 日
i suggest you use the command "readtable" , see this link https://www.mathworks.com/help/matlab/ref/readtable.html
  4 件のコメント
Ben Keshet
Ben Keshet 2018 年 12 月 25 日
thanks. sorry for the basic question - how do I handle this variable?
I got a cell type variable (<1X11 cell>).
eventually I want to plot each of the columns from column 3-11 vs time to view the time trending.
Thanks.
Walter Roberson
Walter Roberson 2018 年 12 月 27 日
time = datenum( strcat(DataCell{:,1}, {' '}, DataCell{:,2}) );
numerics = cell2mat(DataCell(:,3:11));
plot(time, numerics);
datetick('x', 'MM:ss.fff'); %show only minute, second, fraction

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2012a

Community Treasure Hunt

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

Start Hunting!

Translated by