Executing Simulink Code before the Simulation
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Lucas
el 19 de Sept. de 2014
Respondida: Lucas
el 20 de Sept. de 2014
Im am working on a model, which dynamically creates a Route consisting of various parts, which are characterized by a starting point (xyz_start) and an end point (xyz_end). The Route can be created by assembling those parts. Since I want to provide this (static) Route information to other parts of my simulation, I want to calculate the Route information before the actual simulation and store it in a data store memory. The calculation of the Route should not be executed during the simulation. My idea was to make this possible by enabled subsystems and an init parameter, which is 1 while the initialization and 0 while the simulation.
I know I have to work with Callback Functions but how can I execute the Code before the Simulation (e.g. for a specific time period) and change the init parameter after that, so that the Route informations are calculated and stored in the data store memory?
The model is attached. Thanks a lot for your help!
Note to the Data Store Memory: The Size is calculated by the count of Blocks with the Tag 'Strecke'. Rows: Blocks columns: 1 - block (1 if it is already taken, 0 if not) 2 - x-start of block 3 - y-start of block
0 comentarios
Respuesta aceptada
A Jenkins
el 19 de Sept. de 2014
1) You can use a Clock block with a Compare to Constant block to control blocks to only execute during parts of the simulation.
2) Alternatively, you could separate your simulations, so that your Main Simulation calls your Initialization Simulation before it even begins. In your MainSimulation.mdl, go to File->Model Properties->Callbacks->InitFcn, and add
sim('CreateRouteBeforeExecution')
Then you proabably need to add ToWorkspace and FromWorkspace blocks to pass the data between the two simulations.
0 comentarios
Más respuestas (1)
Ver también
Categorías
Más información sobre Programmatic Model Editing en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!