Mar 14

Optional arguments for Matlab functions

Tag: softwareadmin @ 9:53 am

The standard way to handle optional arguments in a Matlab function is to put them at the end of the call list and only include them if you want to change them. This has a lot of problems. First, what do you do if you want to change an argument that is somewhere in the middle of the list but leave the rest unchanged? Some would suggest just putting commas for the unchanged arguments but as far as I know the behavior is undefined. Does this substitute an empty variable ‘[]‘ for the other arguments? Also, this makes it hard to read the code. You have to count up the number of commas to figure out which argument is being changed.

more →