passing parameters to dynamically-linked functions

Jaroslav Hajek highegg at gmail.com
Wed Aug 6 09:18:55 CDT 2008


On Thu, Jul 31, 2008 at 10:09 PM, Thomas L. Scofield
<scofield at calvin.edu> wrote:
>
> Parameters in Matlab are often passed in the manner
>    functionName ( ..., 'parameterName', 'parameterValue' )
> I am wondering if there is an established approach for organizing such
> parameters, perhaps in a cell array(?), so that they are easily passed on to
> and parsed within a dynamically-linked function.  Perhaps the kind of answer
> I am looking for goes like this: "for an example, see the m-file ______
> which accepts additional parameters like these and then passes them along to
> the dynamically-linked function _______."
>

You can also find the following trick convenient:

options.parameter_name = "IDontLikeCamelCasing"; % default value
% ...etc
for i = first_param_name:2:nargs
  options.(varargin{i}) = varargin{i+1};
endfor

now to query for option option1 you do `options.option1'. Handling map
in a DLD function is also simple.

> Thomas L. Scofield
> --------------------------------------------------------
> Associate Professor
> Department of Mathematics and Statistics
> Calvin College
> --------------------------------------------------------
>



-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


More information about the Octave-maintainers mailing list