FAQ: How do I handle .mat file initialization in my Simulink models?
Question
My Simulink model contains custom library blocks that depend on parameters loaded from external .mat files. When I run EHANDBOOK Container-Build, the masks do not display correctly because the data from the .mat file is not available. How can I work around this limitation?
Answer
EHANDBOOK Container-Build does not load MATLAB workspace variables or external .mat files automatically during model processing. This is a known limitation (see MATLAB Workspace or mat-Files Limitation).
However, you can work around this by using Simulink’s PreLoadFcn callback to load your .mat file automatically whenever the model is opened—including when EHANDBOOK Container-Build processes it.
Solution Overview
-
Create a MATLAB script that loads your
.matfile -
Add the script name to your Simulink model’s
PreLoadFcncallback -
Include the script directory in the
-simlibparameter when running EHANDBOOK Container-Build
This ensures that your .mat file is loaded into the MATLAB workspace before your model is processed, allowing custom block masks to display correctly.
Support
If you need further assistance, please contact our Support Center at http://www.etas.com/en/hotlines.php?langS=true&