# How can I create global initialization variables or parameters that work anywhere in the model hierarchy?

**URL:** <https://forum.plexim.com/t/how-can-i-create-global-initialization-variables-or-parameters-that-work-anywhere-in-the-model-hierarchy/846>\
**Category:** PLECS\
**Tags:** parameter, variable, global\
**Created:** [August 27, 2020, 5:30pm UTC](https://forum.plexim.com/t/how-can-i-create-global-initialization-variables-or-parameters-that-work-anywhere-in-the-model-hierarchy/846 "2020-08-27T17:30:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rcolbeck](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@rcolbeck](https://forum.plexim.com/u/rcolbeck)\
**Post date:** [August 27, 2020, 5:30pm UTC](https://forum.plexim.com/t/how-can-i-create-global-initialization-variables-or-parameters-that-work-anywhere-in-the-model-hierarchy/846/1 "2020-08-27T17:30:35Z")

</div>

Hello:

In the Initialization tab of the Simulation parameters, can I have variables that work anywhere in the hierarchy of the model. i.e. global? At the moment, I create different variables and then I always have to create a mask for the top level block and pass the variables down. i.e.

In Initialization tab:

Rds=100e-3;

Then in the top-level block, I would have to have a parameter Rds equal to Rds and then use Rds in the block at the level below, and keep doing that if I wanted to pass that variable further down the hierarchy.

I’m wondering if I can avoid having to create a mask for the blocks in the hierarchy, with parameters for each of my variables, and just have a global variable I can use anywhere in the hierarchy.

Thanks,….Roger

---

<div class="post-metadata">

**Author:** ![Kris\_Eberle](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/kris_eberle/32/6_2.png) [@Kris\_Eberle](https://forum.plexim.com/u/Kris_Eberle)\
**Post date:** [August 27, 2020, 7:54pm UTC](https://forum.plexim.com/t/how-can-i-create-global-initialization-variables-or-parameters-that-work-anywhere-in-the-model-hierarchy/846/2 "2020-08-27T19:54:41Z")

</div>

Hi Roger,

Good question. Unfortunately I do think you need to define all mask variables used inside a subsystem _if_ you mask it. But if you don’t create the mask, the variables can be passed down the layer without needing to initialize them.

Another option I can think of for certain blocks (gains, controllable sources, etc.) would be to define the variable (variable(s) with a vector) in a Constant block at the top-level, then use Signal To/Signal From to send the setpoint to your target block in a lower layer elsewhere in the model. This would obviously not be a solution for defining block parameters at a lower level.

Best regards,

Kris

---

<div class="post-metadata">

**Author:** ![rcolbeck](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@rcolbeck](https://forum.plexim.com/u/rcolbeck)\
**Post date:** [August 27, 2020, 11:40pm UTC](https://forum.plexim.com/t/how-can-i-create-global-initialization-variables-or-parameters-that-work-anywhere-in-the-model-hierarchy/846/3 "2020-08-27T23:40:16Z")

</div>

Thank-you Kris. Ah now that explains why at first I had some variables that were working but then after I created a mask for the top-level block, I started getting error messages about undefined variables. I hadn’t put two and two together.

The vector idea is interesting.

…Roger
