Ask Your Question

Revision history [back]

Looking at the documentation for the Mat_ object type I found this sample code.

Mat_<double> M(20,20);
for(int i = 0; i < M.rows; i++)
    for(int j = 0; j < M.cols; j++)
        M(i,j) = 1./(i+j+1);

So I am guessing the problem with your code is that you are assigning values to the matrix the same moment that you are creating it. Use a for loop structure to fill the elements that can easily be read ouy from a Mat_ type by indexing.

Looking at the documentation for the Mat_ Mat_ object type I found this sample code.

Mat_<double> M(20,20);
for(int i = 0; i < M.rows; i++)
    for(int j = 0; j < M.cols; j++)
        M(i,j) = 1./(i+j+1);

So I am guessing the problem with your code is that you are assigning values to the matrix the same moment that you are creating it. Use a for loop structure to fill the elements that can easily be read ouy from a Mat_ type by indexing.