Function:
The MATLAB function has one output and several input arguments, most of which are optional, that is:
output=MyFunction(arg1,arg2,opt1,opt2,...,optN)
What I want to do:
I would like to provide only the function arg1, arg2 and the last optional input argument optN. I used the tilde operator as follows:
output=MyFunction(str1,str2,~,~,...,true)
Undesirable result:
This gives the following error message:
Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.
The error indicates a comma after the first tilde, but I do not know what to do with it, to be honest.
Problem Identification:
- I am using MATLAB 2013b, which supports the tilde operator.
According to the MATLAB documentation, the above function call should work:
You can ignore any number of functional inputs at any position in the argument list. Separate consecutive tildes with a comma ...
I think there are some workarounds, such as using '' or [] as input, but I would really like to understand how to use '~' correctly, because in fact leaving the input, I can use the existing ( ) when checking the input arguments of a function.
If you need more information from me, please let me know.
Many thanks!
function matlab tilde
DMueller
source share