How can I use InputParser with multiple argument names?
1 ビュー (過去 30 日間)
I would like to use InputParser with multiple possible argument syntax for the same argument. For instance, to have shorter versions, e.g. that I can do:
with the same result. I tried to use InputParser with cell arrays or char arrays but that does not work. Does someone know how to do this?
その他の回答 (1 件)
Fangjun Jiang 2018 年 1 月 11 日
編集済み: Fangjun Jiang 2018 年 1 月 11 日
Since "PartialMatching" is true by default, do_something('f',2) is same as do_something('factor',2) if you don't have another parameter name starting with 'f'. In that case, you don't need to do anything extra in terms of InputParser.
If you do have multiple parameter names starting with 'f', I would specify both 'factor' and 'f' as optional argument. Inside the function, you can have processing to treat the parameters the same. But I guess it will not work if the argument is required.