In MATLAB, the line below converts a Matrix to a Vector.It flattens the matrix column by column into a vector.
myvar(:)
Ho
If you wanna change the matrix values without defining a new variable you can use
Eigen::MatrixXd A(2,3);
A.data()[3] = 1.2
in this case data()[3] will correspond to index A[1,1] of matrix, or read them by
double value = A.data()[5];
so if I write down the whole 2by3 matrix it would be like
A.data()[0] A.data()[2] A.data()[4]
A.data()[1] A.data()[3] A.data()[5]