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

  1. Create a MATLAB script that loads your .mat file

  2. Add the script name to your Simulink model’s PreLoadFcn callback

  3. Include the script directory in the -simlib parameter 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.

Implementation Steps

For detailed step-by-step instructions, see:

This guide includes: * Creating the loader script * Configuring the PreLoadFcn callback * Running EHANDBOOK Container-Build with the correct parameters * A complete working example

Support

If you need further assistance, please contact our Support Center at http://www.etas.com/en/hotlines.php?langS=true&;