- Create your custom MATLAB Level-2 S-function and save it in a directory on the MATLAB search path.
- Create a 'makecfg.m ' script in the same directory as your MATLAB Level-2 S-function file.
- In the "Code Generation" section present in the "Configuration Parameters" dialog box for your Simulink model, set the "System target file" parameter to the appropriate value for your platform.
- In the same section, set "Generate makefile" to "on" then select "Makefile" for the "Template makefile" parameter and finally set "Make command" to the command-line command that you want to use to invoke the make process.
- Generate C code for your Simulink model that uses your custom MATLAB Level-2 S-function. Simulink will generate a makefile for your model.
- Open the generated makefile and at the end of the makefile, add the following lines and then save the changes.
Simulink Code gen does not invoke makecfg.m for custom Matlab L2 S-function.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
It seems that there is no invokation of makecfg.m for customizing the build directive in case of custom Matlab L2 S-functions.
It seems that the makecfg.m will only be called in case a .mex simulink block binary is present.
Can anyone confirm regarding this behavior?
Thanks!
0 Kommentare
Antworten (1)
Vandit
am 1 Jun. 2023
Hi,
Yes, the 'makecfg.m' function is only called if a '.mex' Simulink block binary is present. This is because the '.mex' file contains all the necessary information for compiling the S-function, including the build directive. If there is no '.mex' file, then 'makecfg.m 'is not called and the S-function will be compiled with the default build directive. The reason for this behavior is that the '.mex' file is a compiled binary file, and it is not possible to modify the build directive after the file has been compiled. If you need to customize the build directive for a custom Matlab L2 S-function, then you will need to create a '.mex' file.
To invoke 'makecgf.m' file for customizing the build directive in case of custom Matlab L2 S-functions, follow the steps given below:
# Invoke makecfg to customize build settings
MATLAB_ROOT = $(MATLAB)
include $(MATLAB_ROOT)/extern/lib/$(TARGET_ARCH)/mwci/mwmakefile
7.Modify the 'makecfg' script to include the desired build options and commands and save the required changes.
8.Run make command to build your Simulink model and your custom MATLAB L2S-function using customized makefile.
By following these steps, you should be able to invoke makecfg.m for customizing the build directive in case of custom MATLAB Level-2 S-functions within Simulink.
To know more about how to use makecfg to Customize Generated Makefiles for S-Functions refer to the link below:
Hope this helps.
Thankyou
1 Kommentar
Siehe auch
Kategorien
Mehr zu Simulink Coder finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!