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

E
Emmanuel · Sep 19, 2020 · 2.9K views
Question
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 PhD Expert
Answered Aug 27, 2026

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')
100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!