how to create function without having to use all the inputs in the script
古いコメントを表示
i have a function with many inputs how can i write this function so i would not have to fill all the inputs? for example now i have this function
T=Tavg('none',12,[],[])
to avoid using the last 2 inputs i must set them to empty array in the script
採用された回答
その他の回答 (1 件)
James Tursa
2014 年 10 月 24 日
Use nargin in your function to determine how many inputs are actually being passed in. E.g.
function T = Tavg(a,b,c,d)
if( nargin == 2 )
c = something; % c wasn't passed in
d = something; % d wasn't passed in
end
etc.
カテゴリ
ヘルプ センター および File Exchange で Call MATLAB from C++ についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!