how to create function without having to use all the inputs in the script
Show older comments
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
Accepted Answer
More Answers (1)
James Tursa
on 24 Oct 2014
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.
Categories
Find more on Call MATLAB from C++ in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!