I have a large Simulink model consisting of several subsystems, piping sections for example. Each subsystem is modeled with a m-function. Within the m-function I throw warnings (for now I use matlab warnings but I could only print the information) when specific conditions occur in the pipings.
I would like to trace the warning message to the full path of the block calling the m-function, in order to inform the user of which piping is causing the trouble. I have tried using gcb
in my m-functions but it is not supported by the code generation capabilities of Simulink, which I need.
Is there another approach to get the whole trace of a warning in this use case ?
I managed pass an identifier to the MATLAB Function
blocks allowing me to trace the origin of prints or warnings afterwards, by following these steps :
MATLAB Function
.MATLAB function
in the function definition. This step requires specifying the entry as a Parameter Data
within the Modeling/Symbols Pane panel.MATLAB Function
blocks.Note : I did not manage to pass the path to the block (model_name/subsystem/subsytem2/etc...
) as a string as intended, but instead relied on the fact that I have a numerical identifier for each block of the model, which is specific to my application.
I believe this can be improved, maybe with a more generic answer, but this has solved my issue in my application for now.