% loop over the entire pool of unus and record the distributions from the % metadata and pom & wg from WOT; use a stucture array with substructures % to accommodate the varying data formats and sample sizes for k = total_unu_keys_entire_pool:-1:1 % backwards to allocate structure arrays current_unu_key = unu_keys_entire_pool(k); flags_all_variables(k,1) = k; flags_all_variables(k,2) = current_unu_key; % analysing the metadata, one variable at a time if ismember(current_unu_key, unu_keys_time_use) flags_all_variables(k,3) = 1; % locate the current unu and record into a general structure current_rows = find(all_entries_unu_keys_time == current_unu_key); allunudata(k).distributions.raw_timespan = all_entries_timespan(current_rows); allunudata(k).distributions.raw_cdf_time_use = all_entries_cdf_time_use(current_rows); end % if unu_keys_entire_pool(k)==301 % allunudata(k).distributions.raw_cdf_time_use % disp('debugging...') % end if ismember(current_unu_key, unu_keys_time_storage) flags_all_variables(k,4) = 1; % locate the current unu and record into a general structure current_rows = find(all_entries_unu_keys_time == current_unu_key); allunudata(k).distributions.raw_timespan = all_entries_timespan(current_rows); allunudata(k).distributions.raw_cdf_time_storage = all_entries_cdf_time_storage(current_rows); end if ismember(current_unu_key, unu_keys_stock_use) flags_all_variables(k,5) = 1; current_rows = find(all_entries_unu_keys_stock == current_unu_key); allunudata(k).distributions.stockspan = all_entries_stockspan(current_rows); allunudata(k).distributions.freq_stock_use = all_entries_freq_stock_use(current_rows); end if ismember(current_unu_key, unu_keys_stock_storage) flags_all_variables(k,6) = 1; current_rows = find(all_entries_unu_keys_stock == current_unu_key); allunudata(k).distributions.stockspan = all_entries_stockspan(current_rows); allunudata(k).distributions.freq_stock_storage = all_entries_freq_stock_storage(current_rows); end if ismember(current_unu_key, unu_keys_fate) flags_all_variables(k,7) = 1; current_rows = find(all_entries_unu_keys_fate == current_unu_key); allunudata(k).distributions.cats_primary_fate = all_entries_cats_primary_fates(current_rows); allunudata(k).distributions.freq_fate = all_entries_freq_fates(current_rows); else allunudata(k).distributions.cats_primary_fate = cats_primary_fate; % assign the fate categories extracted earlier in the code end flags_all_variables(k,8) = sum(flags_all_variables(k,3:7)); % sum across the binary flags for the 5 variables % analysing POM and WG data if ismember(current_unu_key, unu_keys_pom_units) current_rows = find(all_entries_unu_keys_pom_units == current_unu_key); allunudata(k).timeseries.pom_units(:) = all_entries_timeseries_pom_units(current_rows,:); end if ismember(current_unu_key, unu_keys_pom_weightpu) current_rows = find(all_entries_unu_keys_pom_weightpu == current_unu_key); allunudata(k).timeseries.pom_weightpu(:) = all_entries_timeseries_pom_weightpu(current_rows,:); end if ismember(current_unu_key, unu_keys_wg_tonnes) current_rows = find(all_entries_unu_keys_wg_tonnes == current_unu_key); allunudata(k).timeseries.wg_tonnes(:) = all_entries_timeseries_wg_tonnes(current_rows,:); end end