rtwbuild doesn't generate modelsources.txt in MATLAB 2023
6 views (last 30 days)
Show older comments
I have used rtwbuild in MATLAB 2020a and it generated modelsources.txt.
MATLAB 2023a doesn't generate this file. Please help me to solve it.
2 Comments
Shivam Gothi
on 23 Aug 2024
Edited: Shivam Gothi
on 23 Aug 2024
Hello,
Can you please share the screenshot of the error message?
or elaborate the issue
Accepted Answer
Shivam Gothi
on 26 Aug 2024
Hello,
I took a simulink model and generated the code for them in R2020a and R2023a version. The "modelsources.txt" was present in R2020a version, but not in R2023a. But, the rest of the files were present in both of them. Basically, the "modelsources.txt" file only contains the name of simulink model. May be, with the newer version of MATLAB, the "modelsources.txt" file is not created by the compiler because it is redundant.
Therefore, it cannot be called an error / issue.
More Answers (1)
Shivam Gothi
on 26 Aug 2024
Edited: Shivam Gothi
on 26 Aug 2024
Hello Trung Nguyen Thanh,
I understand that you are trying to generate the code for Simulink model in MATLAB version R2023a, using “rtwbuild”. The code was generated in MATLAB 2020a version, but it is having some issue with MATLAB R2023a version.
I have tried to generate a c-code in R2023a, for a Simulink model, and it compiled without any error.
Here are the steps which can help you to generate a c code for your Simulink model (R2023a):
Step1 : Make a valid Simulink model in R2023a, run the simulation and save it to the location that is in the search path of MATLAB. To see the search path of MATLAB, go to MATLAB command window and type the command “path”. The first path appearing in the list will be the current working folder. Save your Simulink model in that folder.
Step-2: Configure the model properties.
- Open the “Configuration parameters “. It is found under the “Modelling” tab of Simulink window.
- Under “Configuration parameters” select the “Solver” options and make the following changes as shown in below figure.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1760054/image.png)
NOTE : The solver must be configured for “fixed step size”. The sample time can vary according to the application. Here, I have selected it as 1e-8.
Step 3: Now navigate to the “Code Generation” tab under “Configuration parameters” and make the following changes as shown below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1760059/image.png)
NOTE : You must have a tool chain installed for code generation to work. Follow the below steps to install a tool chain.
- Go to “Add-on” options under “Home” tab in MATLAB window. Search for “MATLAB Support for MinGW-w64 C/C++/Fortran Compiler” in the search bar of “ADD-ON Explorer”. As shown in below image.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1760064/image.jpeg)
- Click “install”.
Step 4 : Now go to the MATLAB command window and type the “rtwbuild” command, with the Simulink model name. A sample code below illustrates this.
modelName = 'fault_creation2';
rtwbuild(modelName);
NOTE : (Here the name of Simulink model is “fault_creation2.slx”);
The code generation will start and you will see the status messages in command window. Once the build has completed, you will be able to see a separate folder created in the current working folder. The conventional naming of folder will be:
“filename_grt_rtw”. This folder contains the header and the source files for a modular c-code.
Plaese refer to the following MATLAB documentation links:
I hope this resolves the issue.
4 Comments
Shivam Gothi
on 26 Aug 2024
What "system target file" you are using? I am using rsim.tlc as shown in below image.
May be, that might be causing difference.
Tell me your "system target file", I will also build the model using the same...
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1760194/image.jpeg)
See Also
Categories
Find more on Simulink Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!