Inputting Date Time data and presenting as a graph

3 次查看(过去 30 天)
A = importdata('08_underwater.txt')
A = readtimetable('08_underwater.txt')
A.Properties.VariableNames{1} = 'Light';
A.Time.Format='M/dd/yyyy HH:mm'
plot(A.Time,A.Light)
^ with this the x axis appears totally wrong as I am plotting data for only 01/12/21 - 03/12/21
Light is correctly displayed on the y axis
I would like to show light changes over time over the three days
I am wondering if the x axis requires more formatting?

回答(1 个)

Chunru
Chunru 2021-12-7
A = readtimetable('08_underwater.csv')
Warning: The DATETIME data was created using format 'MM/dd/uuuu HH:mm:ss' but also matched 'dd/MM/uuuu HH:mm:ss'.
To avoid ambiguity, supply a datetime format using SETVAROPTS, e.g.
opts = setvaropts(opts,varname,'InputFormat','MM/dd/uuuu HH:mm:ss');
A = 675×1 timetable
Datetime Light ___________________ _____ 01/12/2021 09:35:00 100.6 01/12/2021 09:40:00 111.4 01/12/2021 09:45:00 106.2 01/12/2021 09:50:00 86.2 01/12/2021 09:55:00 87.3 01/12/2021 10:00:00 88.8 01/12/2021 10:05:00 100.5 01/12/2021 10:10:00 110.5 01/12/2021 10:15:00 124 01/12/2021 10:20:00 137.3 01/12/2021 10:25:00 143.4 01/12/2021 10:30:00 150.6 01/12/2021 10:35:00 159.7 01/12/2021 10:40:00 152.7 01/12/2021 10:45:00 134.4 01/12/2021 10:50:00 106.8
A.Properties.VariableNames{1} = 'Light';
plot(A.Datetime,A.Light)
  29 个评论
Chunru
Chunru 2021-12-13
Use the same data and code here.
opts = detectImportOptions('08_underwater.csv');
opts = setvaropts(opts, 'Datetime', 'InputFormat', 'dd/MM/uuuu HH:mm');
% type 08_underwater.csv
A = readtable('08_underwater.csv', opts);
plot(A.Datetime,A.Light)
Sophia
Sophia 2021-12-13
Perfect, thanks so much for your help! Really appreciate it

请先登录,再进行评论。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by