MATLAB: How to define different behaviours in the custom TLC file for different versions of MATLAB in Simulink Coder 8.3 (R2012b)

simulink coder

I would like to define different behaviour depending on the MATLAB version being used for my custom TLC file.

Best Answer

It is possible to use if/else code structures in TLC in order to generate code dependant on the version of MATLAB or the TLC version that is being used. For example:
%if ISEQUAL:(TLC_VERSION, "a_tlc_version")
<text and directives to be processed if version is equal to "a_tlc_version">
%else

<text and directives to be processed if version is not equal to "a_tlc_version">
%endif

In the example above we use the ISEQUAL TLC directive. Alternatively you could use FEVAL to call a MATLAB function to query the version information. For example the VERLESSTHAN command
%if FEVAL("verLessThan", "matlab", "8.0")
<text and directives to be processed if the MATLAB version is R2012a or older>
%else
<text and directives to be processed if the MATLAB version is R2012b or newer>
%endif
Using this command you can access all the version information you can access from MATLAB.