This forum is disabled, please visit https://forum.opencv.org

1 | initial version |

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.

2 | No.2 Revision |

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.

Copyright OpenCV foundation, 2012-2018. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.