getarg

Get named argument from varargin
1,5K Downloads
Aktualisiert 2. Mär 2012

Lizenz anzeigen

Get named argument from varargin.
If nargout==1 returns the value. The value will be an empty cell if not found, or the default value if specified. If nargout==2, returns varargin with the argument removed, and the value.

Example:

out = doSomething( in, 'myOptionValue', 2 );

function out = doSomething( in, varargin )

%get the value specified by 'myOptionValue', return default value of 3.14 of not found.
[varargin,myOptionValue] = getarg( varargin, 'myOptionValue', 3.14 );
myOptionValue=myOptionValue{:};

%function body...

end

Zitieren als

Ivar Eskerud Smith (2024). getarg (https://www.mathworks.com/matlabcentral/fileexchange/35415-getarg), MATLAB Central File Exchange. Abgerufen .

Kompatibilität der MATLAB-Version
Erstellt mit R2011b
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux
Kategorien
Mehr zu Argument Definitions finden Sie in Help Center und MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Veröffentlicht Versionshinweise
1.0.0.0