octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: passing parameters to dynamically-linked functions


From: Jaroslav Hajek
Subject: Re: passing parameters to dynamically-linked functions
Date: Wed, 6 Aug 2008 16:18:55 +0200

On Thu, Jul 31, 2008 at 10:09 PM, Thomas L. Scofield
<address@hidden> 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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]