% % ----------------- % Copyright © 2022 ACK Cyfronet AGH, Poland. % -------------- % function columnIdx = findCatalogColumn(catalog, colName) % FINDCATALOGCOLUMN Find the index of a column in a catalog % % columnIdx = FINDCATALOGCOLUMN(catalog, colName) returns the index of % the column with the specified name within the given catalog structure. % The catalog is expected to be an array of structures where each % structure has a 'field' representing the column name. % % Example: % catalog(1).field = 'ID'; catalog(2).field = 'Time'; % idx = findCatalogColumn(catalog, 'Time'); % % Result: idx = 2 % % For more details on the catalog format, refer to the documentation: % https://docs.cyfronet.pl/display/ISDOC/Catalog+-+description % % Note: This function is intended to be used in conjunction with other % catalog processing functions. % % See also: EXTRACTCOLUMNS. for c = 1:length(catalog) if strcmp(catalog(c).field, colName) columnIdx = c; break; end end if exist('columnIdx') ~= 1 error('no column named %s', colName); end end