Neglection of [outport]variable generated for bus assignment block
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens

My intention is to generate th code as mentioned below
void computeArea() {
rectangle.area = rectangle.length * rectangle.width;
}
Réponses (2)
Akshat Dalal
le 30 Jan 2025
Modifié(e) : Akshat Dalal
le 30 Jan 2025
Hi Gowtham,
As per the image you attached and some guesswork, this could be because you're using virtual buses throughout the model. Virtual buses are just an graphical affordance to avoid cluttering the model and make it look cleaner. However, internally the member variables are considered as separate entities. You will have to use a non-virtual bus which actually treats the different variables as a single entity. You may refer the following documentations for more information:
- https://www.mathworks.com/help/simulink/ug/getting-started-with-buses.html
- https://www.mathworks.com/help/simulink/ug/create-nonvirtual-buses.html
Thanks
Akshat
0 commentaires
Shivam Gothi
le 30 Jan 2025
Modifié(e) : Shivam Gothi
le 30 Jan 2025
As I do not have the simulink model, I tried to make a simple simulink model to reproduce the issue as shown below. I am also attaching it with this answer.

I was able to generate code that was of format:
void computeArea() {
rectangle.area = rectangle.length * rectangle.width;
}
You just need to do some optimisation setting under "Model Configurations -> Code Generation -> Optimisation:". I have done the following optimisation settings:
CASE-1: buid code for Generic real time (.grt)
below given are the optimisation settings:


The screen-shot of generated code is:

CASE-2: Build code for embedded real time (.ert)
below given are the optimisation settings:



The screenshot of generated code is:

I hope you find this useful !
6 commentaires
Voir également
Catégories
En savoir plus sur Naming Conventions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
