# vector of matrix

How do i initialize a vector of Matrix of type float. Each matrix has 5 rows and 1 column initialized to [0,0,0,0,0]

I could only get to vector<mat_<float>> random;

I have no clue how to initialize size of each Mat. Help thanks

if you can live with stack-based Matx types, it could be:

(you can't do that with 'heap' based Mat or Mat_<float>, since the data from the initialization would be shared among all elements)

@berak you mean that :

because memory used by v[0] is same that v[1], v[2]...as push_back just make a field copy of x

I have a doubt Is my answer good?

@LBerger, imho, your answer below is the obvious and correct solution.

but yes, if you push_back() shallow copies of the same Mat, they all will point to same data. it's the same problem with:

`vector<Mat> V(123,Mat(5,1,CV_32F,0.0f)); // all point to same data`

(i just wanted to show up an alternative, but thinking twice about it, i'll rather delete it for being too confusing)

@berak No don't delete I have learn something! After there is many ways to go somewhere.

thanks all :)