https://www.mathworks.com/help/matlab/matlab_prog/check-function-inputs-with-validateattributes.html
Check Function Inputs with validateattributes - MATLAB & Simulink
This example shows how to verify that the inputs to your function conform to a set of requirements using the validateattributes function.
checkfunctioninputsmatlabsimulink