rtwbuild doesn't generate modelsources.txt in MATLAB 2023

2 Ansichten (letzte 30 Tage)
Trung
Trung am 23 Aug. 2024
Bearbeitet: Trung am 27 Aug. 2024
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 Kommentare
Shivam Gothi
Shivam Gothi am 23 Aug. 2024
Bearbeitet: Shivam Gothi am 23 Aug. 2024
Hello,
Can you please share the screenshot of the error message?
or elaborate the issue
Trung
Trung am 26 Aug. 2024
Bearbeitet: Trung am 27 Aug. 2024
This is the difference in rtwbuild between MATLAB 2020a and MATLAB 2023a:
2020a:
2023a:
In MATLAB 2023a, after rtwbuild function, it does not generate file modelsources.txt which contains subsystem_name.c

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Shivam Gothi
Shivam Gothi am 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.
  1 Kommentar
Trung
Trung am 27 Aug. 2024
Bearbeitet: Trung am 27 Aug. 2024
Ok, So this is normal for matlab 2023a.
Thank you for your dedicated support.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Shivam Gothi
Shivam Gothi am 26 Aug. 2024
Bearbeitet: Shivam Gothi am 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.
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:
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.
  • 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 Kommentare
Trung
Trung am 26 Aug. 2024
Bearbeitet: Trung am 26 Aug. 2024
modelsources.txt file contains subsystem_name.c
Shivam Gothi
Shivam Gothi am 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...

Melden Sie sich an, um zu kommentieren.

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!

Translated by