Reading CSV file with time stamped data and Plotting data with Time in the X-axis
Show older comments
I have a csv file with data imported from a PLC time stamped to msec. I wanted to use the following "csvread" command to read the data and plot the data with time on the x axis.
Time Data format 12:38:06;865 (HH:MM:SS;FFFF) See attached csv file
Can you please assist me to be able read the timestamp in Matlab and plot the data
Accepted Answer
More Answers (1)
Peter Perkins
on 12 Jan 2017
I'm not familiar with PLC files, but in anything like a recent MATLAB, you should be able to use readtable and datetime. Something like
t = readtable('Test1.csv','Format','%{HH:mm:ss;SSS}D,%f%f%f%f')
Not sure if the file has column headers, you may need to adjust the table's variable names. It looks like you'll want to convert the datetime to a duration, because it would have been read in with the date portion set to "today". Something like
t.Time = t.Time - datetime('today');
t.Time.Format = 'hh:mm:ss.SSS'
should do that. Then plot as
plot(t.Time,t.GVPos)
Hope this helps.
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!