11-12-2004 12:48 PM
11-15-2004 12:26 PM
11-15-2004 02:52 PM
11-15-2004 03:02 PM
11-16-2004 09:50 AM
11-10-2005 12:22 PM
I am using Measurement Studio and MS VS 2003 C++ and MFC (not managed).
My app requires that I process multiple sequences of data, accumulate the sequences as vectors in a matrix, then chart each of the vectors. Each sequence is added to a CNiReal64Vector. Then each vector is assigned to a row in a CNiReal64Matrix. I have to do it this way since each run has an unknown variable number of vectors, so everything is done in loops.
Once I have made a matrix of vectors, how do I refer to each of them when I want to plot the vectors using PlotXvsY for example. The compiler complains when I try to refer to the data in the matrix in a variety of the seemingly obvious ways.
CNiReal64Matrix mvx(10,10000);
CNiReal64Matrix mvy(10,10000);
CNiReal64Vector vx;
CNiReal64Vector vy;
in a loop data points are added:
vx.Append(some double value);
vy.Append(some double value);
Then, vectors are assigned to the matrix:
mvx.AssignRow(rownum, vx);
mvy.AssignRow(rownum, vy);
vy.SetSize(0);
vx.SetSize(0);
...and repeat the loop above for next vector....
...later I need to plot each vector in the matrix...
m_Graph.Plots.Item(plotnum).PlotXvsY(mvx[plotnum], mvy[plotnum]);
....and it is not obvious at this point how to access/refer to a vector in the matrix???
Any help would be appreciated.
Thanks
MikeeyG
11-15-2005 07:30 AM
CNiReal64Vector v(30,3.14); // vec with 30 elements, all set to 3.14 CNiReal64Matrix m(2,3,3.14); // 2 x 3 matrix with all elements set to 3.14 double d = v[0]; // Access first element double e = m(0,0); // Access 'first' element(2) If you want to get a certain column or row of a matrix into a vector, you can use the CNiMatrixT<>::CopyColumn or CNiMatrixT<>::CopyRow method. For example:
CNiReal64Matrix m(2,3,3.14); // 2 x 3 matrix with all elements set to 3.14 CNiReal64Vector v; // empty vector m.CopyRow(0,v); // v now has a copy of row 0Note that this method is making a copy of the matrix's data, rather than pointing to it or referencing it.