How to find streaks in a categorical vector?
Mostra commenti meno recenti
Hi,
is there a way to identify streaks in a categorical vector? Considering number vectors, I've found out that it might be useful to work with the functions find and diff but as this problem is concerned with a categorical vector, this does not work. Is there a workaround or would I need to convert my categorical vector into a number vector?
Many thanks for your help!
The table below illustrates my plan:
+--------+--------+
| CatVec | SerVec |
+--------+--------+
| A | 1 |
+--------+--------+
| C | 1 |
+--------+--------+
| A | 1 |
+--------+--------+
| B | 1 |
+--------+--------+
| B | 2 |
+--------+--------+
| C | 1 |
+--------+--------+
| A | 1 |
+--------+--------+
| A | 2 |
+--------+--------+
| A | 3 |
+--------+--------+
| B | 1 |
+--------+--------+
| C | 1 |
+--------+--------+
| C | 2 |
+--------+--------+
2 Commenti
Image Analyst
il 30 Apr 2020
Did you look at the findgroups() function?
Ameer Hamza
il 30 Apr 2020
To easily solve this problem, It will be much easier to use double datatype as compared to categorical. You can simply use double() to convert the categorical array to the double array.
Risposta accettata
Più risposte (1)
Vimal Rathod
il 5 Mag 2020
0 voti
You can use "findgroups" function to make groups in Categorical Data. The function accepts the data as categorical data so you don't need to change your data.
Refer to the following link to know more about the function.
Categorie
Scopri di più su App Building in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!