defaultValue - set default value for optional arguments

バージョン 1.0.0.0 (1.03 KB) 作成者: Luca Amerio
Assigns default value to funtion optional input variable
ダウンロード: 49
更新 2016/1/27

ライセンスの表示

DEFAULTVALUE Assigns default value to funtion input variable
DEFAULTVALUE ('NAME',VAL) check if variable NAME doesn't exist or
is empty. If this is the case, it assigns it the value VAL.
DEFAULTVALUE ('NAME',VAL,EMPTYVAL) assigns value VAL to variable
NAME if it doesn't exists or value EMPTYVAL if it's empty.
NOTE: The variable value IS NOT the function output. The function must
be called without output

Example:
function c=sumab(a,b)
% This function can be called either with one or two input arguments
narginchk(1,2)
defaultValue('b',1)
c=a+b;

By Luca Amerio
luca.amerio@polimi.it
27/01/2016

引用

Luca Amerio (2024). defaultValue - set default value for optional arguments (https://www.mathworks.com/matlabcentral/fileexchange/55120-defaultvalue-set-default-value-for-optional-arguments), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2015b
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersPerformance and Memory についてさらに検索
タグ タグを追加

Community Treasure Hunt

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

Start Hunting!
バージョン 公開済み リリース ノート
1.0.0.0