LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

XYZ Surface plot on the go?

Solved!
Go to solution

Hello Labview experts.

Is there anyone that can help me with plotting an XYZ surface plot on the go?  What i mean by on the go is that I'm scanning two directions (X, Y) on a surface, and for each (X,Y) pair I'm measuring one Z value.  X and Y are pre-determined two 1D arrays, but the Z values are not an array, they are single values one by one at each iteration in a for loop.  Yes, when the the loop is done the Z values will be an array and the XYZ plot will look like the attached picture below, but i want a Surface plot that updates every-time a Z value is acquired.  Your help will be very much appreciated.

Message 1 of 10
(4,258 Views)

How do surface plots look when the Z direction is full of NaN values?  Start with that, maintain Z array in a shift register, and replace the elements in the Z array one by one on each iteration.

Message 2 of 10
(4,245 Views)

Thanks for the reply.  But the Z is not a direction, it is an indicator (something measured, it has a value).  I don't know why you assumed i have some NaN Z values??? I have no NaN at all

0 Kudos
Message 3 of 10
(4,238 Views)

When my scan is done and I acquired all the Z values, yes it will plot fine.  But my question is I want it to update the surface plot every time an Z value is acquired.

To simplify, at each iteration on the for-loop I'm sending a pair of (X,Y) values (to move the two stages in X and Y directions to the desired positions), and a sub VI inside the loop returns a value of Z (measured something, can be voltage, current, etc).  Yes when the loop is done, i will have three 1D arrays (one for X, one for Y, and one for Z) and i can plot the surface just fine.  I want the surface plot to get updated at each iteration of the for-loop

0 Kudos
Message 4 of 10
(4,232 Views)
Solution
Accepted by RavensFan

@soleil2500 wrote:

Thanks for the reply.  But the Z is not a direction, it is an indicator (something measured, it has a value).  I don't know why you assumed i have some NaN Z values??? I have no NaN at all


I'm sorry I used the wrong word.  I meant what happens if the Z "array" is full of NaN.  Initialize an array of NaN values, then replace them one by one as you get real values.  In normal graphs, NaN values are not plotted.

 

Like attached.

 

0 Kudos
Message 5 of 10
(4,227 Views)

In this case, does the graph have to be placed outside the loop or inside the loop?  (inside the loop Z is not an array yet).  If outside the loop it means the array will be completed after the loop is done

0 Kudos
Message 6 of 10
(4,218 Views)

RavensFan is correct. I have used this method myself in the past, it works fine with 3D surface graphs.

 

0xDEAD

 

0 Kudos
Message 7 of 10
(4,215 Views)

Have the graph inside the loop, preallocate a 2D array of NaN outside the loop, maintain it inside a shift register, use replace array subset to insert the Z values.

 

0xDEAD

0 Kudos
Message 8 of 10
(4,214 Views)
Solution
Accepted by topic author soleil2500

Have a snippet. Its nearly Christmas.

 

Here X and Y are arrays of 10 elements (0-9)

Z is a 10x10 2D array of NaN.

 

On each iteration one NaN is replaced with a random number.

 

Surface_snip.png

0 Kudos
Message 9 of 10
(4,209 Views)

Thank you very much

0 Kudos
Message 10 of 10
(4,180 Views)