Ask Your Question
0

How to create a Mat (1D) with sequential values?

asked 2017-07-05 19:25:40 -0600

ambikav gravatar image

In Matlab following can be done -

Matrix=startVal:endVal; which results in a row vector with first element of startVal, incremented by one each time and last value being endVal.

Is there a similar way to create a 1D Mat in openCV?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-07-05 19:53:59 -0600

berak gravatar image

updated 2017-07-05 19:55:17 -0600

no, no such thing built in.

you simply set up your Mat, and fill it with numbers, manually:

Mat m(1,10,CV_64F); // 10 doubles in a single row
for (int i=0; i<10; i++)
      m.at<double>(0,i) = i; // set the column in row 0

note, that there are notorious differences between c++ and matlab, like 0 or 1 based indexing, so careful !

edit flag offensive delete link more

Comments

Great. Thanks!

ambikav gravatar imageambikav ( 2017-07-14 10:29:18 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-07-05 19:25:40 -0600

Seen: 2,833 times

Last updated: Jul 05 '17