Histogram using Date Stamps
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Sophia Salazar
le 26 Juil 2019
Commenté : Sophia Salazar
le 26 Juil 2019
I have three years of dates and I want to know how to make a histogram only taking months into consideration.
The data is in datestam format, so when I plot a histogram is separates the months for each year.
How do I do this?
Thanks!
3 commentaires
Adam Danz
le 26 Juil 2019
That's clearer! If you get stuck with the recommendation in my answer, leave a comment and I can try to help further.
Réponse acceptée
Guillaume
le 26 Juil 2019
Oh, if it's the histogram of the dates you want, then groupsummary may not be the best tool (sorry Adam!)
histogram(yourdatetimevector.Month, 'BinMethod', 'integers')
2 commentaires
Plus de réponses (1)
Adam Danz
le 26 Juil 2019
Modifié(e) : Adam Danz
le 26 Juil 2019
If your data are organized in a table or array, use groupsummary() (requires r2018a). The groupbin should be 'monthname'(see Guillaume's comment below). Then feed that summary data into historgram().
[update]
If you're just counting the number of months in a datetime vector, you can use month() along with histcounts().
% dt is your datetime vector
c = histcounts(month(dt),1:13);
mo = {'jan' 'feb' 'mar' 'apr' 'may' 'jun' 'jul' 'aug' 'sep' 'oct' 'nov' 'dec'};
histogram('categories',mo,'BinCounts',c)
3 commentaires
Voir également
Catégories
En savoir plus sur Discrete Data Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!