# Create PLECS circuits automatically with MATLAB code

**URL:** <https://forum.plexim.com/t/create-plecs-circuits-automatically-with-matlab-code/2527>\
**Category:** PLECS\
**Tags:** matlab, simulink\
**Created:** [August 28, 2025, 9:32am UTC](https://forum.plexim.com/t/create-plecs-circuits-automatically-with-matlab-code/2527 "2025-08-28T09:32:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Heiko93](https://avatars.discourse-cdn.com/v4/letter/h/d26b3c/32.png) [@Heiko93](https://forum.plexim.com/u/Heiko93)\
**Post date:** [August 28, 2025, 9:32am UTC](https://forum.plexim.com/t/create-plecs-circuits-automatically-with-matlab-code/2527/1 "2025-08-28T09:32:42Z")

</div>

Hello everyone,

my Name is **Heiko** and I have a Question. Topic: Create PLECS circuits automatically with MATLAB code

I would like to use MATLAB code to automatically generate PLECS Circuits in Simulink.  
I usually use the following command in MATLAB:  
add\_block

Example code:  
`new_system(‘Example’);`  
`open_system(‘Example’);`  
`add_block([‘fl_lib/Electrical/Electrical Elements/Resistor’], [Example/R_1’]);`

works perfectly.

For the PLECS Blockset, I first create:  
`add_block(‘plecslib/Circuit’, [‘Example/PLECS Circuit’]);`

Then I want to insert a resistor into the PLECS Circuit:  
`add_block([‘plecslib/Components/Electrical/Passive Components/Resistor’], [Example/PLECS Circuit/R_1’]);`

The PLECS Circuit is inserted correctly into SImulink, but then the following error message appears:  
_There is no block named ‘plecslib/Components/Electrical/Passive Components/Resistor’_

Thanks for your support

**Heiko**

---

<div class="post-metadata">

**Author:** ![Bryan\_Lieblick](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/bryan_lieblick/32/10_2.png) [@Bryan\_Lieblick](https://forum.plexim.com/u/Bryan_Lieblick)\
**Post date:** [August 28, 2025, 1:15pm UTC](https://forum.plexim.com/t/create-plecs-circuits-automatically-with-matlab-code/2527/2 "2025-08-28T13:15:04Z")

</div>

Hello Heiko,

There currently is not a way to build PLECS models and place components via a scripting interface. The `plecslib/Components` Mask does not itself contain any Simulink components, but rather launches the PLECS Blockset model library. Once inside the PLECS Circuit component, then everything is modeled using the PLECS framework where one cannot directly use Simulink commands, but can use the commands described in the PLECS Manual under _Simulation Scripts + Command Line Interface in PLECS Blockset_

Thanks,

Bryan

---

<div class="post-metadata">

**Author:** ![Heiko93](https://avatars.discourse-cdn.com/v4/letter/h/d26b3c/32.png) [@Heiko93](https://forum.plexim.com/u/Heiko93)\
**Post date:** [August 28, 2025, 3:04pm UTC](https://forum.plexim.com/t/create-plecs-circuits-automatically-with-matlab-code/2527/3 "2025-08-28T15:04:19Z")

</div>

Hello Bryan,

my name is **Heiko**. Thank you for answering my question.

**Heiko**
