How do I set default values for functions parameters in MATLAB?
Asked 07 September, 2021
Viewed 1.4K times
  • 57
Votes

Is it possible to have default arguments in MATLAB?

For instance, here:

function wave(a, b, n, k, T, f, flag, fTrue=inline('0'))

I would like to have the true solution be an optional argument to the wave function. If it is possible, what is the proper way to do this?

Currently, I am trying what I posted above and I get:

??? Error: File: wave.m Line: 1 Column: 37
The expression to the left of the equals sign is not a valid target for an assignment.

16 Answer