Converting HH:MM:SS into decimal days to make a time series
12 次查看(过去 30 天)
显示 更早的评论
I need to make a timeseries across three days (7th June - 9th June 2010) - I'm unsure how to include both the time and days across the x-axis?
I think I need to convert into decimal days but I'm unsure on how to do this and combine both days and time.
Seperate timeseries plots need to be made for the mean phosphate and nitrate concentrations in surface and bottom waters, again I'm not sure how to do this!
Any help will be grateful, the excel sheet is attached.
采纳的回答
Cris LaPierre
2020-12-12
编辑:Cris LaPierre
2020-12-12
Use a datetime. When you plot, your data type is honored. You can use xtickformat to format how the data appears.
% Define date and time formats for import
opts = detectImportOptions("CTD12-17.xlsx");
% nice, but not necessary
opts.VariableNamingRule = "preserve";
opts = setvartype(opts,"Time","duration");
opts = setvaropts(opts,"Time","InputFormat","hh:mm:ss","DurationFormat","hh:mm:ss");
% Set datetime format for Date + Time
opts = setvartype(opts,"Date_TimeCombined","datetime");
opts = setvaropts(opts,"Date_TimeCombined","InputFormat","dd/MM/yy HH:mm:ss");
% Load data
data = readtable("CTD12-17.xlsx",opts)
%Plot
plot(data.("Date + Time Combined"),data.("Bottom Water Mean N+N"))
3 个评论
Cris LaPierre
2020-12-12
Ah, because the Date+Time column format is incorrect. I specified it as MM/dd/yy but it is actually dd/MM/yy. I've updated and rerun my original post.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!