problem plotting excel date, cant convert to HH:MM:SS only

조회 수: 5 (최근 30일)
erkelly
erkelly 2019년 12월 9일
답변: Eric Sofen 2019년 12월 13일
I have been fighting with this data for a little while I've managed to do most of what I want with it.
Currently I am having issues with plotting. The data I have is over the course of 2+ days, however my experiment doesnt start until ~20 hours in. The way time is recorded is either like this:
0.000347222223354038
0.000694444446708076
which I can plot. However, with this I count to 24 and then start over, or start at 18:00:00 rather than zero. The experiment time ranges from 12 to 20 hours.
Tthe other 'time' data column that starts at zero when the experiment starts and counts total time, but I can't seem to import it correctly into matlab. 'readmatrix(file.csv)' gives NaN for that column. I can get the column as text if I do '[num, text, both] = xlsread(file.csv)' but I can't seem to convert it to a datenum or anything that matlab will recognize to plot.
this is the type of date that matlab won't read: '1899-12-30 00:00:00'
Any ideas for how I can either read the data, or somehow convert my datetime (ex:0.000347222223354038) into total time starting at time = zero?
Thanks

답변 (1개)

Eric Sofen
Eric Sofen 2019년 12월 13일
I'm not entirely clear about what your data looks like. Attaching a file would help. That said, I suspect readtable would do the trick. Readmatrix expects all of the data to be the same type. In readtable, timestamps like '1899-12-30 00:00:00' would be read as a MATLAB datetime variable. You might want to subtract off the first element from all of the datetimes to get a vector of durations (time since the start of recording - your distinction between the start of the file and start of the experiment confused me).

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by