Create a vector in 15-minute intervals (from 0 am to 24 pm)
15 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi everyone!
I need to create a bar graph with the x axis in 15-minute intervals (from 0 am to 24 pm). Can someone help me to create a vector to do this with HH:MM on the plot?
0 Kommentare
Antworten (1)
Walter Roberson
am 13 Jun. 2021
Bearbeitet: Walter Roberson
am 13 Jun. 2021
Sure, you can xticks() with datetime objects if you have a datetime ruler.
The problem is being able to read it. Every 15 minutes for a day is 96 ticks.
Though for your purposes, perhaps just leaving out the xticks() call on this example would be enough for your purposes.
BT = datetime('yesterday')
T = BT + minutes(sort(1440*rand(1, 500)));
T(1:10)
V = rand(size(T))
ticks = BT + minutes(0:15:1440);
Vdis = accumarray(discretize(T(:), ticks), V(:), [length(ticks),1]);
bar(ticks, Vdis)
xticks(ticks)
4 Kommentare
Walter Roberson
am 19 Jun. 2021
Bearbeitet: Walter Roberson
am 19 Jun. 2021
as_minutes = 0:15:(24*60)-1;
as_days = as_minutes ./ (24*60);
y = rand(size(as_days)); %something to plot
plot(as_days, y);
datetick('x', 'HH:MM')
Siehe auch
Kategorien
Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!