# Define a matrix of inputs in C-Script

**URL:** <https://forum.plexim.com/t/define-a-matrix-of-inputs-in-c-script/1232>\
**Category:** PLECS\
**Tags:** inputs, c-script, define\
**Created:** [April 20, 2023, 3:02pm UTC](https://forum.plexim.com/t/define-a-matrix-of-inputs-in-c-script/1232 "2023-04-20T15:02:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Magdalini](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@Magdalini](https://forum.plexim.com/u/Magdalini)\
**Post date:** [April 20, 2023, 3:02pm UTC](https://forum.plexim.com/t/define-a-matrix-of-inputs-in-c-script/1232/1 "2023-04-20T15:02:28Z")

</div>

I am trying to define many inputs (voltages in a multilevel converter) as a matrix and not one by one. Could anyone help me?

Thank you 🙂

---

<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:** [April 24, 2023, 10:02am UTC](https://forum.plexim.com/t/define-a-matrix-of-inputs-in-c-script/1232/2 "2023-04-24T10:02:13Z")

</div>

See the excerpt from the C-Script help below.

Say you have a 3x3 matrix. If I’m understanding your question correctly, one could:

Set the Number of Inputs field be “9”. There will be one input port to the C-Script block. Access the matrix entries as InputSignal(0, 3\*Row + Column)Set the Number of Inputs field be “[3, 3, 3]”. The C-Script will have 3 input ports, each with three elements. Access the matrix entries as InputSignal(Row,Column)

 ![61](https://europe1.discourse-cdn.com/flex006/uploads/plecs/original/1X/ff8d6d599c03a1398a0621455f94e3467c7ee0ab.jpeg)
