Matlab type arrays in C++

Viewed 12487

How to define arrays in C++/ Open CV as I do in matlab ?

for example:

x=a:b:c;

or

y=linspace(a,b,n);
8 Answers

This is a simple implementation if you use openCV.

Mat linspace(double &startP,double &Endp,int &interval)
{
    double spacing = interval-1;
    Mat y(spacing,1,CV_64FC1);
    for (int i = 0; i < y.rows; ++i)
    {
        y.at<double>(i) = startP + i*(Endp - startP)/spacing;
    }
    return y;
}
Related