arguments - 声明函数参量验证 - MATLAB - MathWorks 中国

arguments[ (Input|Output)] % default: Input

argName/options.optName [(dimensions)] class {validators}

end


validators: func1, func2,…

e.g.

arguments
  factor double = 1
end

HINT: class or validators is optional

Too complex, here I’d like to just give a demo

e.g.

arguments

a % a is a must, no typing checking

b (1,:) % size is forced