Code covered by the BSD License  

Highlights from
Optional function arguments

Be the first to rate this file! 11 Downloads (last 30 days) File Size: 4.92 KB File ID: #38881

Optional function arguments

by

 

Optional function arguments with default values: optndfts

| Watch this File

File Information
Description

Optional function arguments with default values: optndfts

Allows optional arguments to be specified as name value pairs, and
  default values given for those augments not specified e.g.

function strt=demo(arg1,varargin) % insert values to replace defaults
strt=optndfts(varargin,'aa',1,'bb',2,'cc',3); % default values
return % optndfts returns a struct
end

demo(arg1,'bb',22,'aa',11)
ans =
    aa: 11
    bb: 22
    cc: 3

Result is a struct, input values can be list of name value pairs,
  cell array of name value pairs, or a struct.

Acknowledgements

This file inspired Linfitregsel Term Selection In Linear Regression, Greyboxbuild: Complete A Greybox Model, and Greyboxeval Model Quality Evaluation.

Required Products MATLAB
MATLAB release MATLAB 8.0 (R2012b)
Other requirements Will run in many earlier Matlab versions.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.

Contact us