MATLAB: How to generate code of equal simulink blocks only once

code generationoopsimulink

Hi,
In my model I have various LUTs that are equal and after code generation I noticed that Simulink generates code for each LUT block.
So, since the LUTs are equal I would like to know if it is possible to generate code only for one LUT block?
Thank you, André

Best Answer

If you place the LUTs into atomic subsystems, you can take advantage of the Function Packaging options and generate a reusable function.
Take a look at these examples for an idea:
Also, if you want to make sure your multiple instances of the LUT subsystems are all identical so they map to the same reusable function, I'd highly recommend placing them inside a block library.
- Sebastian