Min/Max with string match criteria
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
OliverH
le 21 Juil 2015
Réponse apportée : Walter Roberson
le 21 Juil 2015
I want to find the minimum and maximum date for each unique string value.
e.g. X = ['a'; 'b']
Y = ['a'; 'a'; 'a'; 'a'; 'a'; 'b'; 'b'; 'b'; 'b'; 'b']
Z = [736000; 736001; 736002; 736003; 736004; 736012; 736013; 736014; 736015; 736016]
X is each unique string in Y.
Y and Z are the same size.
Z is the datenum.
Output is the min and max datenum for each entry in X.
0 commentaires
Réponse acceptée
Walter Roberson
le 21 Juil 2015
[tf, idx] = ismember(Y, X); %not X, Y!
minZ = accumarray(idx(:), Z, [], @min);
maxZ = accumarray(idx(:), Z, [], @max);
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Dates and Time dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!