14

Possible Duplicate:
Default Arguments in Matlab
How to deal with name/value pairs of function arguments in MATLAB

What if you need to create a function with tones of optional parameters. Is there a way to call that functions later on naming passed arguments for readability:

foo(123, and=456)
Community
  • 1
  • 1
Grief Coder
  • 6,508
  • 9
  • 38
  • 51
  • @Andrey: I don't think the linked question is an exact duplicate, though I was sure that we've had this question before; I just can't seem to find it. – Jonas Dec 17 '12 at 01:22
  • http://stackoverflow.com/questions/13719346/specifying-optional-function-parameters-selectively-in-matlab – Spectre Dec 17 '12 at 06:58

1 Answers1

12

The comparable way of doing this in Matlab is to have name/value pairs:

foo(123,'and',456,'something',[1 2 3])

See the answers to this question on how to deal with them.

Community
  • 1
  • 1
Jonas
  • 74,690
  • 10
  • 137
  • 177
  • 4
    There's a new way: https://de.mathworks.com/help/matlab/ref/arguments.html When using the arguments block for validation, starting with 21a, one can call a function with the `fun(argname=value)` syntax. – j-hap Apr 20 '21 at 10:08