Min/Max with string match criteria
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
OliverH
am 21 Jul. 2015
Beantwortet: Walter Roberson
am 21 Jul. 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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 21 Jul. 2015
[tf, idx] = ismember(Y, X); %not X, Y!
minZ = accumarray(idx(:), Z, [], @min);
maxZ = accumarray(idx(:), Z, [], @max);
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Dates and Time finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!