MATLAB: How to add profiling code for reference models in the profile hook tlc

hookmodelprofilereferencesimulink codertlc

I have been generating code to get timing data for the major subsystems using a profile hook tlc file. I send in a list of subsystem names from the code generation script and then match it to system.Name to determine if profiling code is to be generated. This doesn't work if the system I am looking for is a referenced model.
How do I get the model name inside the hook functions?

Best Answer

You can get the system name using the following code. This code handles the model reference case.
%function GetSystemName(system) void
%if IsBaseSystem(system)
%assign ssName = CompiledModel.Name
%else
%assign ssName = FEVAL("regexprep",system.Name,"\<S.*\>\/","")
%endif
%return ssName
%endfunction
Related Question