2024-08-28 17:22:21 +02:00
|
|
|
%
|
|
|
|
% -----------------
|
|
|
|
% Copyright © 2022 ACK Cyfronet AGH, Poland.
|
|
|
|
% --------------
|
|
|
|
%
|
|
|
|
function columnIdx = findCatalogColumn(catalog, colName)
|
2024-08-29 13:11:12 +02:00
|
|
|
% 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
|
|
|
|
%
|
2024-08-29 13:51:45 +02:00
|
|
|
% For more details on the catalog format, refer to the documentation:
|
|
|
|
% https://docs.cyfronet.pl/display/ISDOC/Catalog+-+description
|
|
|
|
%
|
2024-08-29 13:11:12 +02:00
|
|
|
% Note: This function is intended to be used in conjunction with other
|
|
|
|
% catalog processing functions.
|
|
|
|
%
|
|
|
|
% See also: EXTRACTCOLUMNS.
|
|
|
|
|
|
|
|
for c = 1:length(catalog)
|
2024-08-28 17:22:21 +02:00
|
|
|
if strcmp(catalog(c).field, colName)
|
|
|
|
columnIdx = c;
|
|
|
|
break;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if exist('columnIdx') ~= 1
|
|
|
|
error('no column named %s', colName);
|
|
|
|
end
|
2024-08-29 13:11:12 +02:00
|
|
|
end
|