Specify datenum starting value
7 views (last 30 days)
Show older comments
Sander Ustrup
on 28 Mar 2021
Answered: Star Strider
on 28 Mar 2021
Hello everyone,
So I'm trying to make a plot with datenum on the X-axis and outdoor temperature on the y-axis.
I have data from 11 AM - 11 AM the folllowing day.
What i would like to do is have my X-axis start at 11 AM, and end at 11 AM.
However when i plot with the datenum I get the current result

What i would like is the following plot, with dates on the x-axis.

My code is the following:
%% Data
time = [
'11:00:00'
'11:15:00'
...
'10:45:00'
'11:00:00'
];
outdoor_T = [
8.55
8.55
...
5.6
5.6
];
%% Plots
DateNumber = datenum(time, 'HH:MM:SS');
figure
plot(DateNumber, outdoor_T)
datetick('x', 'HH:MM:SS', 'keeplimits')
ylabel('Celcius degrees'), xlabel('Hour of the day')
title('Outdoor temperature')
I tried looking at the documentation for datenum, and unfortunately couldn't find an answer.
I hope my question makes sense, otherwise please ask me to elaborate.
Best regards,
Sander
0 Comments
Accepted Answer
Star Strider
on 28 Mar 2021
It will be necessary to combine the dates with the time values in order to do what you want. In most instances, this is relatively straightforward, however I would need to see your data to determine how best to do it.
0 Comments
More Answers (0)
See Also
Categories
Find more on Dates and Time 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!