# How to separate each element of a matrix

**URL:** <https://root-forum.cern.ch/t/how-to-separate-each-element-of-a-matrix/52072>\
**Category:** Newbie\
**Created:** [October 24, 2022, 3:38pm UTC](https://root-forum.cern.ch/t/how-to-separate-each-element-of-a-matrix/52072 "2022-10-24T15:38:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dil](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dil/32/26887_2.png) [@Dil](https://root-forum.cern.ch/u/Dil)\
**Post date:** [October 24, 2022, 3:38pm UTC](https://root-forum.cern.ch/t/how-to-separate-each-element-of-a-matrix/52072/1 "2022-10-24T15:38:15Z")

</div>

Hello all,  
Maybe this is a simple question.But I can’t figure it out.  
I have a TVectorD.  
(1).I need to store it each element separately.  
How can I do that?

Vector (6) is as follows

```
 | 1 |

```

* * *

0 |0.0308705  
1 |-0.0258366  
2 |0.00377313  
3 |-0.000258603  
4 |-0.00151154  
5 |-0.00100335

Thanks  
Dil

---

<div class="post-metadata">

**Author:** ![Dil](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dil/32/26887_2.png) [@Dil](https://root-forum.cern.ch/u/Dil)\
**Post date:** [October 24, 2022, 6:09pm UTC](https://root-forum.cern.ch/t/how-to-separate-each-element-of-a-matrix/52072/2 "2022-10-24T18:09:11Z")

</div>

Hello,  
Tried

```auto
double matrix_element[6];
TVectorD my_matrix;
for(int i=0; I < 6; I++){
 matrix_element[I]= my_matrix.GetMatrixArray() 
}

```

Doesn’t work. I got all six 0’s.  
Any help would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [October 24, 2022, 6:14pm UTC](https://root-forum.cern.ch/t/how-to-separate-each-element-of-a-matrix/52072/3 "2022-10-24T18:14:29Z")

</div>

“`matrix_element[i] = my_matrix[i];`” or “`matrix_element[i] = my_matrix(i);`”
