- each set of lan and lot (there's more than 10000 of them)
- each set of lan and lot with exactly 10 observations
- each set of lan and lot with exactly 10 observations for years 2010 to 2019
- each set of lan and lot with at least 10 observations
make separate table for sets of lat lon that appears x times in a big table.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
SChow
le 13 Oct 2023
Réponse apportée : Star Strider
le 13 Oct 2023
Hi I have a big table 'A' (attached) and I am trying to make multiple tables out of it. Each for a set of lat and long that appears 10 times(for the years from 2010-2019) in the big table. So the new tables will be 10x 'n' (where n is the number of columns in A).
Sorry I do not have a systematic code to put up here.
Many thanks
1 commentaire
Harald
le 13 Oct 2023
Hi,
it is not clear to me what result you are looking for.
A = readtable("who_ambient_air_quality_database_version_2023_(v6.0).xlsx", "Sheet", "Update 2023 (V6.0)");
A = sortrows(A, ["latitude", "longitude", "year"]);
sequenceOf10 = find(A.latitude(1:end-9) == A.latitude(10:end) & ...
A.longitude(1:end-9) == A.longitude(10:end))
From the code, you can see that not all set appear 10 times, and some appear more often (when sequenceOf10 contains consecutive numbers). So, would you like to have a table for...
If I think about it more, I could probably come up with additional interpretations of the question.
Best wishes,
Harald
Réponse acceptée
Star Strider
le 13 Oct 2023
T1 = readtable('who_ambient_ai...3_(v6.0).xlsx', 'Sheet',3)
tic
[LatLonu,ix1,ix2] = unique([T1.latitude T1.longitude], 'stable','rows'); % Unique Lat & Lon Combinations
LatLonT = accumarray(ix2, (1:numel(ix2))', [], @(x){T1(x,:)}) % Collect Results
toc
TableRowSizes = cellfun(@(x)size(x,1), LatLonT, 'Unif',0);
[MinRows,MaxRows] = bounds([TableRowSizes{:}])
Rows10Idx = find([TableRowSizes{:}]==10) % Indices Of Tables With Exactly 10 Rows
Rows10 = numel(Rows10Idx) % Number Of Tables With Exactly 10 Rows
LatLonT{1} % First Table
LatLonT{end} % Last Table
The accumarray function in general makes life easier for these types of problems!
.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Numeric Types 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!