How do I create a structure in Simulink without MATLAB Function block?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Arkadiusz Kwasniak
le 11 Juin 2019
Commenté : Arkadiusz Kwasniak
le 12 Juin 2019
Hi All,
I am trying to implement a C-like structure in Simulink.
I found the instruction how to do it with MATLAB Function block :
Unfortunately I am not allowed to use MATLAB functions in my Simulink model. That is shy I have a question.
Do You know any other way to create a C-like structure in Simulink without MATLAB function block or MATLAB system block?
I will be very thankful for any information.
0 commentaires
Réponse acceptée
Jason Firth
le 11 Juin 2019
You need to create a bus object. You can do this by calling
myStruct = struct('field1',0,'field2',0);
busInfo = Simulink.Bus.createObject(myStruct);
MyDataStructureType = eval(busInfo.busName);
clear(busInfo.busName)
Then you can export the bus definition to a file by running
Simulink.Bus.save('MyBusDefinitions.m','object',{'MyDataStructureType'})
Then in your simulink model, you can use a bus creator block with the output data type set to "Bus: MyDataStructureType". Or you can create a subsystem with one outport connected to a ground and set the output data type of the output port to "Bus: MyDataStructureType". Then you can use the Bus Assignment block to assign elements to the bus. If you have an existing c-header file that you would like to use as the structure definition in the generated code, you can set the MyDataStructureType.HeaderFile = ''; to your specific header file in the "MyBusDefinitions.m"
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Event Functions 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!