One way of doing this is to pass an empty argument, e.g., mySum([], 2) or mySum(2, []). So, you can add the following conditions:
function myVal = mySum(a, b)
if isempty(a)
a = 1;
end
if isempty(b)
b = 20;
end
myVal = a+b;
end
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!