Add documentation for matlab files
This commit is contained in:
@@ -6,14 +6,36 @@
|
||||
% --------------
|
||||
%
|
||||
function [varargout] = extractColumns(catalog, varargin)
|
||||
for i=1:length(varargin)
|
||||
% EXTRACTCOLUMNS Extracts specified columns from a catalog structure
|
||||
%
|
||||
% [col1, col2, ...] = EXTRACTCOLUMNS(catalog, 'colName1', 'colName2', ...)
|
||||
% extracts the columns with the specified names from the catalog
|
||||
% structure. The catalog is expected to be an array of structures where
|
||||
% each structure has fields 'field' and 'val'. The function returns the
|
||||
% values of the requested columns.
|
||||
%
|
||||
% Example:
|
||||
% catalog(1).field = 'ID'; catalog(1).val = [1, 2, 3];
|
||||
% catalog(2).field = 'Time'; catalog(2).val = [100, 200, 300];
|
||||
% [id, time] = extractColumns(catalog, 'ID', 'Time');
|
||||
% % Result: id = [1, 2, 3], time = [100, 200, 300]
|
||||
%
|
||||
% See also: FINDCATALOGCOLUMN.
|
||||
|
||||
for i = 1:length(varargin)
|
||||
colName = varargin{i};
|
||||
varargout{i} = findColumn(catalog, colName);
|
||||
end
|
||||
end
|
||||
|
||||
function column = findColumn(catalog, colName)
|
||||
for c=1:length(catalog)
|
||||
% FINDCOLUMN Helper function to find the values of a column in a catalog
|
||||
%
|
||||
% column = FINDCOLUMN(catalog, colName) searches the catalog structure
|
||||
% for the specified column name and returns its values. If the column
|
||||
% does not exist, an error is thrown.
|
||||
|
||||
for c = 1:length(catalog)
|
||||
if strcmp(catalog(c).field, colName)
|
||||
column = catalog(c).val;
|
||||
break;
|
||||
@@ -22,4 +44,4 @@ function column = findColumn(catalog, colName)
|
||||
if exist('column') ~= 1
|
||||
error('no column named %s', colName);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user