MATLAB: What is the cause of “In numerictype(s) s must be a scalar constant or a fi” error

I use numerictype in MATLAB function block.
The attached model to causes the following error upon updating:
In numerictype(s) s must be a scalar constant or a fi.
Function 'Unit Delay' (#23.780.794), line 25, column 17:
"numerictype(u)"
Launch diagnostic report.
Component: MATLAB Function | Category: Coder error
Undefined function or variable 'u_d'. The first assignment to a local variable determines its class.
Function 'Unit Delay' (#23.866.869), line 29, column 5:
"u_d"
Launch diagnostic report.
Component: MATLAB Function | Category: Coder error
Errors occurred during parsing of MATLAB function 'Unit Delay'
Component: MATLAB Function | Category: Coder error
Errors occurred during parsing of MATLAB function 'Unit Delay'
Component: Simulink | Category: Block error
An error occurred while propagating data type 'int16' through 'test/Unit Delay'.

Best Answer

The error is caused by the fact that built-in integers, like the int16 constant in the example model you kindly provided, are not treated as fixed point object. 
There is two possible workarounds in this case. 
1. You can set the treatment of inherited Simulink signal types to 'Fixed-point & integer' in the Ports and Data Manager, that is available from the toolbar when editing the MATLAB Fucntion Block. This is shown in the image below
 
2. You can ensure the casting of the input data yourself, so that integers will always be converted to fi objects. The following code segment achieves that and could be used in the MATLAB Function Block:
>> if isinteger(u_in)
>> u = fi(u_in);
>> else
>> u = u_in;
>> end
Please note that the input argument has been changed to 'u_in' in order to allow for proper casting.