# Update Matrix row and column number in real time (ControlP5)

**URL:** https://discourse.processing.org/t/update-matrix-row-and-column-number-in-real-time-controlp5/4232
**Category:** Libraries
**Created:** [October 7, 2018, 9:22pm UTC](https://discourse.processing.org/t/update-matrix-row-and-column-number-in-real-time-controlp5/4232 "2018-10-07T21:22:49Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![anon57009815](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@anon57009815](https://discourse.processing.org/u/anon57009815)
#### Post date: [October 7, 2018, 9:22pm UTC](https://discourse.processing.org/t/update-matrix-row-and-column-number-in-real-time-controlp5/4232/1 "2018-10-07T21:22:49Z")

</div>

CONTROLP5  
Is there a way to update (change) row number and column number of a matrix in real time?

Resources -\> ControlP5 -\> Controllers -\> ControlP5Matrix

---

<div class="post-metadata">

### Author: ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)
#### Post date: [October 8, 2018, 6:06am UTC](https://discourse.processing.org/t/update-matrix-row-and-column-number-in-real-time-controlp5/4232/2 "2018-10-08T06:06:06Z")

</div>

Hi luisArandas,

From the [controlP5 reference](http://www.sojamo.de/libraries/controlP5/reference/), it seems that you have this method that can do what you want:

```auto
public Matrix setGrid(int theCellX, int theCellY)

```

---

<div class="post-metadata">

### Author: ![anon57009815](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@anon57009815](https://discourse.processing.org/u/anon57009815)
#### Post date: [October 8, 2018, 8:40am UTC](https://discourse.processing.org/t/update-matrix-row-and-column-number-in-real-time-controlp5/4232/3 "2018-10-08T08:40:18Z")

</div>

Hello jb4x, my question is can that be updated real time?  
Let’s make an example I create a slider cp5.addSlider -\> and then in the function to get the event I would say get the value from the slider and override the variable that is for example cellX

`void public controlEvent(ControlEvent theEvent){ theCellX = (int)(theEvent.getController("newSlider").getValue()); }`

If I want to change the cells in real time (or columns) in accordance with a slider, how actually would I call that method?  
Best, Luis

---

<div class="post-metadata">

### Author: ![anon57009815](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@anon57009815](https://discourse.processing.org/u/anon57009815)
#### Post date: [October 8, 2018, 8:56am UTC](https://discourse.processing.org/t/update-matrix-row-and-column-number-in-real-time-controlp5/4232/4 "2018-10-08T08:56:57Z")

</div>

This is the way I am approaching -\> and it doesn’t work

 ![20](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/6/6751b71c6b03245b9637b8365e75a213235f52e0.png)
