Duplicating Simulink Blocks within a subsystem

13 visualizaciones (últimos 30 días)
Barry Swevels
Barry Swevels el 22 de Jul. de 2016

Hi,

I'm building a rather complicated SimeEvents model, but made a simple case for the question that I have. I have an entity generator that creates passengers for 2 "Taxi's" (Entity Server). I would like to create a system in which the amount of taxi's is variable, so I made a subsystem in which I added the parameter "Taxi". This parameter is used to know the amount of taxi's for generating new blocks.

Now I use the Initialization tab of the Mask of the Subsystem to build all new blocks (add_block, add_line, set_param,...), such that it builds the model with 1 Entity Server/Terminator leaving from the Entity_Switch for each taxi.

My question: How do I adapt this model such that I can run it multiple times with a different amount of taxi's.

At the moment it doesn't work because the blocks cannot be created once they exist. So, the first simulation works, the second fails. I tried 'delete_block' inside the StopFcn but this failed because the StopFcn is executed within the simulation.

I also thought about just reloading the model before each simulation, such that all created content was removed again, but I didn't manage to get this working either.

In the original problem I have about 7 times the amount of taxis of blocks that need to be created, so copying all blocks by hand for each number of taxi's cannot be the best solution.

Respuestas (0)

Categorías

Más información sobre Programmatic Model Editing 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!

Translated by