Pregunta

I'm working on a really ambitious project right now in Simulink and I want to make it as user friendly as I possibly can.

Basically I'm making a detailed model of an intersection filled with cars. I have a car model block that is masked and you can define position, speed, direction etc. But If a user wants to add cars to the system he has to manually "Copy / Paste" and then connect to right places (For example output to GUI and more)

So is there a way to make this automatic ? That is, the user can specify number of cars and they are automatically added into the model ?

I would attach pictures but I don't have enough reputation yet :)

¿Fue útil?

Solución

There is no out-of-the-box method that will do this automatically.

However through writing various MATLAB scripts and using methods such as get_param, set_param, add_block, add_line, along with other model building functions from the MAPLAB-Simulink API it can be successfully done.

Look at the doc for how to use the above functions. There's a simple example of building a model (showing how to add and connect blocks) here.

Otros consejos

Phil's answer covers how to add blocks and wiring to your model. Another approach is to "refactor" your model to handle number of cars within the simulation. For example, using "for iterator" subsystem you can iterate through each car. Another way is, if each of your car is modeled by a vector then your car model block can work on a matrix with each column representing a car.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top