Create a vector in 15-minute intervals (from 0 am to 24 pm)
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Walter Roberson
el 13 de Jun. de 2021
Editada: Walter Roberson
el 13 de Jun. de 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 comentarios
Walter Roberson
el 19 de Jun. de 2021
Editada: Walter Roberson
el 19 de Jun. de 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')
Ver también
Categorías
Más información sobre Data Distribution Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!