MATLAB: How to perform mathematical operations using integers in the Embedded MATLAB function block

blockdataembeddedemlfunctionint16int32int64int8integermathMATLABsimulinktypeuint16uint32uint64uint8

My model includes an Embedded MATLAB Function block, in which I attempt to perform mathematical operations using data of type integer (e.g., int8, uint8, int16, uint16, etc.). When I simulate my model, the following error is returned:
Expected either a logical, char, single, or double.
Found a int8.
Function 'Embedded MATLAB Function' (#48.131.133), line 5, column 6:
"x1"

Best Answer

This enhancement has been incorporated in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
The ability to perform mathematical operations using integers in an Embedded MATLAB function block is not available in Simulink. This is stated as a caveat in the documentation for the Embedded MATLAB function block under the "Data Type Support" section, available by typing the following at the MATLAB 7.0 (R14) prompt:
web([docroot '/toolbox/simulink/slref/embeddedmatlabfunction.html'])
To work around this issue, perform mathematical operations using data of type double or single; afterwards convert the result to an integer, as accomplished with the following code:
y = int8((single(x1)+single(x2))/single(4));