MATLAB: How to use data variants for code generation

Embedded Codersimulink

I would like to use one model that contains multiple data variants for simulation and code generation. All data variants should be present in the generated code so that I can quickly change the data variants during application initialization without regenerating the code.

Best Answer

A demo and accompanying MATLAB files showing how to create data variants using custom storage classes within Real-Time Workshop Embedded Coder is available at the link below. The demo shows how to use one software build to handle situations where the code is the same but the data is different, reducing your need to build and stock different part numbers for embedded systems.
To install this demo, follow these steps:
1. Download the ZIP-file in the Related Documents/Files section to a temporary folder.
2. Start MATLAB.
3. Execute the following at the MATLAB prompt and record the output value:
matlabroot
4. Extract the ZIP-file with folder names to the directory obtained in the previous step.
5. Execute the following at the MATLAB prompt to register the demo:
rehash toolbox
rehash toolboxcache
6. To start the demo, execute the following at the MATLAB prompt:
rtwdemo_param_variants