I have data with dates and times in separte columns. How do I put them together into a datetime format?

2 ビュー (過去 30 日間)
I have data with dates and times in separate columns. How can I get them combined into a single datetime stamp column?
  4 件のコメント
Jan
Jan 2019 年 3 月 6 日
And what is the wanted result? A Matlab array or table object, another CSV file?
Please add the required details. The readers cannot guess, what you want to do.
Timothy Potter
Timothy Potter 2019 年 3 月 6 日
I wanted a Matlab array against which to plot data. I figured out how to do it by seaching other answers and trial and finally success.
%first they had to be converted to numbers,
dateDt1031 = datetime(Verif181031.Date);
timeDt1031 = Verif181031.Time;
% And then added ( I also subtracted the starting time.).
timeStp1031 = (dateDt1031-strt) + timeDt1031;

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

採用された回答

Peter Perkins
Peter Perkins 2019 年 3 月 11 日
Timothy, in recent versions of MATLAB (since R2018a, IIRC), readtable should read those two columns as a datetime and a duration, and you can just add them. Prior to that, you'lll have to read the times in as text and convert to duration. You can use this File Exchange post. After that, just add o the datetime.
But it looks like maybe you got there on your own!

その他の回答 (1 件)

Timothy Potter
Timothy Potter 2019 年 3 月 11 日
I am working in MATLAB 17b, and yes I found a way to creat a timestamp from the separate columns and plot my data.

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by