MATLAB: Do I not see the equivalent of the MATLAB code when compiling MATLAB file with EMLC command in Real-Time Workshop 7.4 (R2009b)

simulink coder

I have written a MATLAB file and I am trying to generate C-code out of it using the EMLC command.
However, I do not see the equivalent of the MATLAB code in the generated code.
Here is the code I have written:
function rc = main %#ok

%#eml
eml.extrinsic('fopen');
eml.extrinsic('fwrite');
eml.extrinsic('fclose');
fid = eml.opaque('FILE*','NULL'); %#ok
a = 1;
A = functionA(a);
fid = fopen('output.txt','a+'); % Open or create new file for reading and writing. Append data to the end of the file
fwrite(fid,'The output is %f', A);
fclose(fid);
rc = A;
The generated C code does not contain any code to write to the file.

Best Answer

This is expected behavior. If you have code in your MATLAB-file that does not affect the return value directly or indirectly within the scope of the file, it gets optimized out and it will not be included in the generated code.