Why can't I add a block to my model using add_block?

Illustration
Emmanuel - 2020-09-19T09:44:00+00:00
Question: Why can't I add a block to my model using add_block?

I want to add a block in a Simulink model named myModel.mdl. When I open the model and attempt to add a block using the following code: open myModel.mdl add_block('simulink/Sources/In1','myModel/myin1') I sometimes receive the following error: ??? There is no block named 'simulink/Sources/In1'

Expert Answer

Profile picture of Prashant Kumar Prashant Kumar answered . 2025-11-20

The Simulink library must be loaded to programmatically add blocks in a model. The LOAD_SYSTEM function can be used to programmatically load the Simulink library as in this example:

load_system('simulink')

open myModel.mdl

add_block('simulink/Sources/In1','myModel/myin1')


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!