Spiting Cell Array into Different Delimiter Numbers
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Yuan Jun Lim
le 12 Nov 2019
Réponse apportée : Akira Agata
le 12 Nov 2019
Hi, I have this set of array, and I would like to spilt it into different numbers. One set of "Dive" is 1, and for the next dive is 2 and so on.... it will keep incrementing when theres a new set of Dive to Walk.
It should be like this
Final Results :
0 commentaires
Réponse acceptée
Akira Agata
le 12 Nov 2019
How about the following?
% Example of the input array
Act = repmat({'Dive';'Run';'Walk'},4,1);
uniqueAct = unique(Act);
Count = nan(size(Act));
for kk = 1:numel(uniqueAct)
idx = strcmp(Act,uniqueAct{kk});
Count(idx) = 1:nnz(idx);
end
T = table(Act,Count);
>> T
T =
12×2 table
Act Count
________ _____
{'Dive'} 1
{'Run' } 1
{'Walk'} 1
{'Dive'} 2
{'Run' } 2
{'Walk'} 2
{'Dive'} 3
{'Run' } 3
{'Walk'} 3
{'Dive'} 4
{'Run' } 4
{'Walk'} 4
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Structures 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!