Frequency of unique items per month from timetable data
Afficher commentaires plus anciens
I have a timetable which is read into matlab from an excel sheet with 2 columns: Timestamp and Stat. Stat is a fault code from a machine. Example below-
2120×1 timetable
Timestamp Stat
____________________ ____
24-Jan-2024 11:47:31 0
23-Jan-2024 15:32:32 9999
23-Jan-2024 00:03:41 77
23-Jan-2024 00:00:13 294
22-Jan-2024 10:08:14 0
: :
11-Jan-2018 10:37:42 -20
10-Jan-2018 08:40:38 9999
10-Jan-2018 08:40:16 9998
10-Jan-2018 08:37:33 9999
10-Jan-2018 08:37:30 -21
05-Jan-2018 14:57:37 -20
05-Jan-2018 13:05:53 9999
05-Jan-2018 12:09:39 159
Display all 2120 rows.
I would like to find the frequency of each fault code per month however there are over 100 possible fault codes but usually only 5/6 unique codes occuring multiple times each month so it seems wasteful to have a bin for every possible fault code as this would result in a lot of empty bins.
Is there a way to calculate the frequency of each fault code on a monthly basis based on the individual fault codes appearing in each month? I have considered groupcount and histcount functions but struggled to achieve my objective using either of these based on the Matlab documentation.
Réponse acceptée
Plus de réponses (1)
Eric Sofen
le 27 Fév 2024
I think groupcounts will also solve your problem (it would be helpful to have some sample data in the question in a form I could use directly rather than recreating it):
groupcounts(t,["Timestamp","Stats"],"month")
Catégories
En savoir plus sur Data Type Identification dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!