Possible Duplicate:
How do I retrieve the names of function parameters in matlab?
I’m looking for a way to get all the arguments passed to, or expected my function. The args() command seems to be ideal but is only available for procedures. Is there anyway of doing this.
My reason I want to do this is so I can do my checking in fewer lines. ie check all inputs are numeric by writing one check then executing for all args. So if there is a good alternative I’m open to ideas.
Thanks
You can use
varargin, as petrichor mentioned.vararginis a cell, so you can easily perform validation of all your parameters in one line usingcellfun:The above code runs
validateattributesfor all function parameters. On the other hand, if you want named variables, you can still group them into cells and run specific tests as above: