Yes this is possible, but only if you ahve an Embedded Coder license. You must first configure the library blocks as follows:
Enable code reuse for the library block:
- In the library, right-click the MATLAB Function block my_conv_filter and select Block Parameters (Subsystem) from the context menu.
- In the Function Block Parameters dialog box, set these parameters:
- Select the Treat as atomic unit check box.
- In the Function packaging field, select Reusable function from the drop-down menu.
The, you must configure your model to place the generated code in a "shared" location that all models can access:
- Select "Simulink" from Simulink menu
- Select "Model Configuration Parameters"
- Select the "Code Generation" tab on left hand side
- Set System Target file to "ert.tlc"
- Select "Interface" on left hand side
- Set Shared Code Placement to "Shared Location"
Now, when you generate code, the .c and .h file will be in the directory /slprj/ert/_sharesutils