Home > atmlab > collocations > limstruct2limmat.m

limstruct2limmat

PURPOSE ^

limstruct2limmat Convert limits-struct to limits-matrix

SYNOPSIS ^

function limmat = limstruct2limmat(limits, name_struct)

DESCRIPTION ^

 limstruct2limmat Convert limits-struct to limits-matrix

 This function converts a limits-structure (as input to the user to, for
 example, collocation_read) to a limits-matrix (as wanted by, for example,
 collocation_restrain.

 FORMAT

   limmat = limstruct2limmat(limits, name_struct)

 IN

   limits      structure       Each field is a string with the name of a
                               column. The values are 2x1-arrays
                               describing the range of values the user
                               wants to restrain the data to.
   name_struct structure       Describes the mapping of column names to
                               column numbers.

 OUT

   limmat      Nx3 matrix      First row column numbers; 2nd and 3rd row
                               the ranges as mentioned.

 See also: collocation_restrain

 $Id: limstruct2limmat.m 7619 2012-05-24 15:22:54Z gerrit $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

limstruct2limmat.m

SOURCE CODE ^

0001 function limmat = limstruct2limmat(limits, name_struct)
0002 
0003 % limstruct2limmat Convert limits-struct to limits-matrix
0004 %
0005 % This function converts a limits-structure (as input to the user to, for
0006 % example, collocation_read) to a limits-matrix (as wanted by, for example,
0007 % collocation_restrain.
0008 %
0009 % FORMAT
0010 %
0011 %   limmat = limstruct2limmat(limits, name_struct)
0012 %
0013 % IN
0014 %
0015 %   limits      structure       Each field is a string with the name of a
0016 %                               column. The values are 2x1-arrays
0017 %                               describing the range of values the user
0018 %                               wants to restrain the data to.
0019 %   name_struct structure       Describes the mapping of column names to
0020 %                               column numbers.
0021 %
0022 % OUT
0023 %
0024 %   limmat      Nx3 matrix      First row column numbers; 2nd and 3rd row
0025 %                               the ranges as mentioned.
0026 %
0027 % See also: collocation_restrain
0028 %
0029 % $Id: limstruct2limmat.m 7619 2012-05-24 15:22:54Z gerrit $
0030 
0031 if isempty(fieldnames(limits))
0032     limmat = zeros(0, 3);
0033     return
0034 end
0035 
0036 fields = fieldnames(limits);
0037 C = cell(1, length(fields));
0038 for i = 1:length(fields)
0039     c = fields{i};
0040     if iscell(limits.(c))
0041         C{i} = [name_struct.(c)(limits.(c){1})' repmat(limits.(c){2}, [length(limits.(c){1}) 1])];
0042     else
0043         C{i} = [name_struct.(c)' repmat(limits.(c), [size(name_struct.(c), 2) 1])];
0044     end
0045 end
0046 % C = cellfun(@(c) ...
0047 %     [name_struct.(c)' ...
0048 %     repmat(limits.(c), [size(name_struct.(c), 2) 1])], ...
0049 %     fieldnames(limits), 'UniformOutput', false);
0050 limmat = vertcat(C{:});
0051 end

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