MATLAB: How to add only two choices for an input parameter

inputmatlab functionparameters

I would like a function to accept only 'string1' or 'string2' for param3 i.e.:
output = fun(param1, param2, param3)
What should I add to param3 ?
Thank you

Best Answer

Use assert() to throw error if condition fail
assert(any(strcmp(param3, {'string1', 'string2'})), 'param3 must b string1 or string2')
it will compare param3 to see whether it is 'string1' or 'string2'. If none has detected the function with end an throw an error.