# Importing a parameter in Simulation script and using it as a variable

**URL:** <https://forum.plexim.com/t/importing-a-parameter-in-simulation-script-and-using-it-as-a-variable/831>\
**Category:** PLECS\
**Tags:** plecs, script\
**Created:** [August 10, 2020, 4:07am UTC](https://forum.plexim.com/t/importing-a-parameter-in-simulation-script-and-using-it-as-a-variable/831 "2020-08-10T04:07:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mayuchip](https://avatars.discourse-cdn.com/v4/letter/m/5fc32e/32.png) [@Mayuchip](https://forum.plexim.com/u/Mayuchip)\
**Post date:** [August 10, 2020, 4:07am UTC](https://forum.plexim.com/t/importing-a-parameter-in-simulation-script-and-using-it-as-a-variable/831/1 "2020-08-10T04:07:01Z")

</div>

Hello PLECS users/team,

I am fairly new to PLECS and struggling with calling a variable from my simulation into the simulation script. I am able to call the variable from initialization but not from the simulation. My aim is to call a parameter which is generated in PLECS and use it as a variable inside the simulation script. I have tried plecs(‘get’, ..) command however I am not successful.

Kindly let me know how it can be done. Thanks in advance.

---

<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 12, 2020, 1:50pm UTC](https://forum.plexim.com/t/importing-a-parameter-in-simulation-script-and-using-it-as-a-variable/831/2 "2020-08-12T13:50:11Z")

</div>

Some of the terminology you’re using is not clear to me.

Can you post a simple model showing what you are trying to do? It’s ok if you need to use dummy variables or include in a code comment “I would like to access variable ‘x’ here”.

---

<div class="post-metadata">

**Author:** ![Manu\_Parimi](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/manu_parimi/32/6_2.png) [@Manu\_Parimi](https://forum.plexim.com/u/Manu_Parimi)\
**Post date:** [August 12, 2020, 5:56pm UTC](https://forum.plexim.com/t/importing-a-parameter-in-simulation-script-and-using-it-as-a-variable/831/3 "2020-08-12T17:56:08Z")

</div>

Hello,

As Bryan pointed out it’s not very clear what you’re attempting to do. However, from what I understood I attached a simple example for you.

To retrieve the results from the PLECS simulation to your simulation script, you can either use a scope block or a signal outport block. In the attached example, we calculate the duty cycle “d” of a boost converter from the PLECS simulation, which we can then use in the script for post-processing, or use this value in a second PLECS simulation. Is this similar to what you’re intending to do?

Regards,  
Manu

[boost\_converter\_script.plecs](https://forum.plexim.com/uploads/short-url/kGqPuUTGsG291MHxRZ41Amrunlf.plecs) (14.3 KB)
