Home > atmlab > deprecated > cols_cell_to_cols_struct.m

cols_cell_to_cols_struct

PURPOSE ^

% cols_cell_to_cols_struct Convert a cols-cell-array to a cols-structure

SYNOPSIS ^

function name_struct = cols_cell_to_cols_struct(cols, cols_in)

DESCRIPTION ^

% cols_cell_to_cols_struct Convert a cols-cell-array to a cols-structure

 Convert a cols cell-array such as {'B_LAT', 'B_LONG', 'B_TIME', 'MHS', 3:5, 'MEAN'}
 into a cols-structure such as S.B_LAT=1, S.B_LONG=2, S.B_TIME=3,
 S.MHS=4:6, S.MEAN=7.

 FORMAT

   name_struct = cols_cell_to_cols_struct(col_defs, cols_in)

 IN

   col_defs    structure   as colloc_constants('cols_cpr_mhs')
   cols_in     cell-array  column-names and channel-numbers, as passed to
                           collocation_read

 OUT

   name_struct structure   the names and the correspoding column-numbers
                           cumulatively

 $Id: cols_cell_to_cols_struct.m 7553 2012-04-27 19:08:16Z gerrit $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

cols_cell_to_cols_struct.m

SOURCE CODE ^

0001 function name_struct = cols_cell_to_cols_struct(cols, cols_in)
0002 
0003 %% cols_cell_to_cols_struct Convert a cols-cell-array to a cols-structure
0004 %
0005 % Convert a cols cell-array such as {'B_LAT', 'B_LONG', 'B_TIME', 'MHS', 3:5, 'MEAN'}
0006 % into a cols-structure such as S.B_LAT=1, S.B_LONG=2, S.B_TIME=3,
0007 % S.MHS=4:6, S.MEAN=7.
0008 %
0009 % FORMAT
0010 %
0011 %   name_struct = cols_cell_to_cols_struct(col_defs, cols_in)
0012 %
0013 % IN
0014 %
0015 %   col_defs    structure   as colloc_constants('cols_cpr_mhs')
0016 %   cols_in     cell-array  column-names and channel-numbers, as passed to
0017 %                           collocation_read
0018 %
0019 % OUT
0020 %
0021 %   name_struct structure   the names and the correspoding column-numbers
0022 %                           cumulatively
0023 %
0024 % $Id: cols_cell_to_cols_struct.m 7553 2012-04-27 19:08:16Z gerrit $
0025 
0026 n = 1; i = 1;
0027 while i <= length(cols_in)
0028     if i<length(cols_in) && isnumeric(cols_in{i+1})
0029         dn = length(cols_in{i+1});
0030         di = 2;
0031     else
0032         dn = length(structsearch(cols, cols_in{i}));
0033         di = 1;
0034     end
0035     name_struct.(cols_in{i}) = n:(n+dn-1);
0036     n = n + dn;
0037     i = i + di;
0038 end

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005