getoptions

PURPOSE ^

getoptions - retrieve options parameter

SYNOPSIS ^

function v = getoptions(options, name, v, mendatory)

DESCRIPTION ^

 getoptions - retrieve options parameter

   v = getoptions(options, 'entry', v0, mendatory);
 is equivalent to the code:
   if isfield(options, 'entry')
       v = options.entry;
   else
       v = v0;
   end

   Copyright (c) 2007 Gabriel Peyre

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function v = getoptions(options, name, v, mendatory)
0002 
0003 % getoptions - retrieve options parameter
0004 %
0005 %   v = getoptions(options, 'entry', v0, mendatory);
0006 % is equivalent to the code:
0007 %   if isfield(options, 'entry')
0008 %       v = options.entry;
0009 %   else
0010 %       v = v0;
0011 %   end
0012 %
0013 %   Copyright (c) 2007 Gabriel Peyre
0014 
0015 if nargin<3
0016     error('Not enough arguments.');
0017 end
0018 if nargin<4
0019     mendatory = 0;
0020 end
0021 
0022 if isfield(options, name)
0023     v = eval(['options.' name ';']);
0024 elseif mendatory
0025     error(['You have to provide options.' name '.']);
0026 end

Generated on Thu 10-Dec-2020 17:34:27 by m2html © 2005