I have a function called "getMatlabVersion.m" in my current folder. I'd like to use it in my custom code generation template file to display the MATLAB version in the banner of each source file. I have written a .cgt file that has a line with the following: * MATLAB Version: % However, when I build the above, I get the following error: Code Generation 1 Elapsed: 3 sec Error: File: myCustomTemplate_cgt.tlc Attempt to call a non-function value: GetMatlabVersion Error: File: myCustomTemplate_cgt.tlc Values of NULL type cannot be expanded How do I call my function within my .cgt file?
John Michell answered .
2025-11-20
* MATLAB Version: %
would become
* MATLAB Version: %
* MATLAB Version: %
%function getMatlabVersion() void
%assign outBuffer = ""
%openfile outBuffer
%assign result = FEVAL("getMatlabVersion")
%
%closefile outBuffer
%return outBuffer
%endfunction