Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I set the X and Y vector values manually to be then plotted using PlotY in VC++ - Measurement studio

I need to fill in the vector with x and corresponding y values and then plot it.
0 Kudos
Message 1 of 6
(3,101 Views)
If I understand your question correctly, what you want is the PlotXvsY method and not PlotY. PlotXvsY allows you to specify the X and Y data as independent vectors.

CNiReal64Vector x, y;
GetSomeData(x, y);
myGraph.PlotXvsY(x, y);

Let me know if that is not what you are looking for.

TonyH
Measurement Studio
0 Kudos
Message 2 of 6
(3,101 Views)
Yes, this is what I meant. So, how do I fill in the CNiReal64Vector so that the PlotXvsY function recognizes it?
0 Kudos
Message 4 of 6
(3,101 Views)
The vector is like a C array with some special features. You address its elements with square braces and set the size either in the constructor or with the SetSize method.

If I want to plot the x,y pairs (0,0), (1,1), (2,2), ..., (49, 49) the code would be:

// Create two vectors and set their sizes to 50 points
CNiReal64Vector x(50);
CNiReal64Vector y(50);

// Fill in the vectors with data to plot
for (int i = 0; i < 50; ++i)
{
x[i] = i;
y[i] = i;
}

// Plot the data
myGraph.PlotXvsY(x, y);

TonyH
MeasurementStudio
0 Kudos
Message 5 of 6
(3,101 Views)
Thanks a heap. That was super fast.
0 Kudos
Message 6 of 6
(3,101 Views)
In addition to the PlotXvsY method that Tony mentioned, you may want to also look at the PlotXY method that takes a CNiMatrix.

- Elton
0 Kudos
Message 3 of 6
(3,101 Views)