How do I create a structure in Simulink without MATLAB Function block?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Arkadiusz Kwasniak
el 11 de Jun. de 2019
Comentada: Arkadiusz Kwasniak
el 12 de Jun. de 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 comentarios
Respuesta aceptada
Jason Firth
el 11 de Jun. de 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"
Más respuestas (0)
Ver también
Categorías
Más información sobre Sources en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!