Skip to content
Snippets Groups Projects
Select Git revision
  • clang+openmp
  • master default protected
  • 6.x protected
  • madysson
  • 5.x protected
  • asm
  • time-varying-information-set
  • 4.6 protected
  • dynare_minreal
  • dragonfly
  • various_fixes
  • 4.5 protected
  • exo_steady_state
  • declare_vars_in_model_block
  • julia
  • error_msg_undeclared_model_vars
  • static_aux_vars
  • slice
  • aux_func
  • penalty
  • 6.4 protected
  • 6.3 protected
  • 6.2 protected
  • 6.1 protected
  • 6.0 protected
  • 6-beta2 protected
  • 6-beta1 protected
  • 5.5 protected
  • 5.4 protected
  • 5.3 protected
  • 5.2 protected
  • 5.1 protected
  • 5.0 protected
  • 5.0-rc1 protected
  • 4.7-beta3 protected
  • 4.7-beta2 protected
  • 4.7-beta1 protected
  • 4.6.4 protected
  • 4.6.3 protected
  • 4.6.2 protected
40 results

VERSION.in

Blame
  • varargin2struct.m 1.08 KiB
    function opt=varargin2struct(varargin)
    %
    % opt=varargin2struct('param1',value1,'param2',value2,...)
    %   or
    % opt=varargin2struct(...,optstruct,...)
    %
    % convert a series of input parameters into a structure
    %
    % authors:Qianqian Fang (q.fang <at> neu.edu)
    % date: 2012/12/22
    %
    % input:
    %      'param', value: the input parameters should be pairs of a string and a value
    %       optstruct: if a parameter is a struct, the fields will be merged to the output struct
    %
    % output:
    %      opt: a struct where opt.param1=value1, opt.param2=value2 ...
    %
    % license:
    %     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details 
    %
    % -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
    %
    
    len=length(varargin);
    opt=struct;
    if(len==0) return; end
    i=1;
    while(i<=len)
        if(isstruct(varargin{i}))
            opt=mergestruct(opt,varargin{i});
        elseif(ischar(varargin{i}) && i<len)
            opt.(lower(varargin{i}))=varargin{i+1};
            i=i+1;
        else
            error('input must be in the form of ...,''name'',value,... pairs or structs');
        end
        i=i+1;
    end