LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

structure in plotxy

Hi,
I was wondering whether the PlotXY function can somehow be convinced to accept my dynamically allocated points structure.

typedef struct point{
    double x;
    double y;
    double z;
}point;

point *somepoint;
malloc and fill somepoint;
PlotXY with somepoint.x as x array????

thanks tons in advance!


0 Kudos
Message 1 of 2
(3,086 Views)
Sorry, DocEye,  that's not going to work. The PlotXY function expects all your x-values (and y-values) to be in contiguous memory. It expects something like this:

x1, x2, x3, ....

However, when you pass it an array of structs, even if you pass the address of a specific field in the struct, this is what your memory actually looks like:

x1, y1, z1, x2, y2, z2, x3, y3, z3, ...

and therefore the PlotXY function would be accessing the wrong data. The only way that would work would be if you plotted only one point.

So before calling PlotXY, you'll have to write a function that moves the x and y data into two distinct arrays.

Luis

0 Kudos
Message 2 of 2
(3,064 Views)