12-18-2018 11:49 AM
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.
Solved! Go to Solution.
12-18-2018 12:38 PM
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.
12-18-2018 12:41 PM
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
12-18-2018 12:50 PM
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
12-18-2018 01:03 PM - edited 12-18-2018 01:12 PM
@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.
12-18-2018 01:13 PM
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
12-18-2018 01:21 PM
RavensFan is correct. I have used this method myself in the past, it works fine with 3D surface graphs.
0xDEAD
12-18-2018 01:22 PM
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
12-18-2018 01:34 PM
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.
12-18-2018 04:27 PM
Thank you very much