This is expected since the Interpreted MATLAB Function block is not supported for code generation. To work around the issue, use a MATLAB Function block instead:
You can execute the following command at the MATLAB Command prompt to get the Block Support Table which displays the different blocks which are supported for Code generation:
>> showblockdatatypetable
There, it is mentioned to use the MATLAB Function block as an alternative to the Interpreted MATLAB Function block for code generation.
Differences between MATLAB Function and Interpreted MATLAB Function block:
The MATLAB Function block is compiled before run-time (R2014b and earlier, it generates C code and compiles; R2015a and later, it is compiled just-in time). The Interpreted MATLAB Function block uses the MATLAB interpreter to execute an existing MATLAB function.
If you're just running simulations on your desktop, there won't be much noticeable differences. However, if you're generating code from your model, you cannot do so with the Interpreted MATLAB Function block.
Also, the MATLAB Function block is a more customizable, as you have more control over the properties (size/data type/data scope) of all the variables, you can create tunable parameters in the blocks, etc.
In summary, the MATLAB Function block is much more flexible and we would recommend using it in most situations. The Interpreted MATLAB Function block can be easier to set up if you have already have an existing function, and it lets you use the full range of MATLAB as long as you're using the model strictly for desktop simulation.
Best Answer