Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to define a matrix with 5000 specific elements

Hello, I need to define a matrix M, M is 5000*2. In matlab, M=[1,45;89,3;....], it's not regular, so I can't define it in a loop. In my code I tried to define it like

Mat M = (Mat_<int>(num, 3) << 994, 323, 0, 4014, 4295, 4395, 4906, 3423, 2792.....);

But when I use printf("number: %f", M.at<double>(2, 1), it gives me 0. So could anyone tell me how to define such a matrix like in matlab M=[1 2 3; 4 5 6;....]