LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Graphing two variables on XY graph

Hello,

 

I am trying to graph two variables, "Real /\V 1-2" vs "Current" on an XY graph to ultimately find the slope and y-intercept, but I would also like to visualize the data in a graph.

 

This may have something to do with the loops surrounding the XY graph, but I don't see any points being plotted on the XY-graph and I only seem to be getting one data point when I export data to Excel. 

 

How can I fix this? I have also tried using the linear fit pt-by-pt function, but the values do not seem to display when I run my VI.

 

Thank you!

0 Kudos
Message 1 of 10
(378 Views)

Your xy graph only contains one point, making a linear fit impossible.

 

You can easily built your data into a suitable array and even do a linear fit of all data so far. No need for ptbypt functions.

Your fit will currently only happen once the while loop has completed after which you do many ptbypt fits in a fast loop and only the final result will be visible (all intermediary results will be too fast to see).

 

 

0 Kudos
Message 2 of 10
(369 Views)

Assuming you want to fit while data is acquired, see if this can give you some ideas....

 

altenbach_0-1729178472949.png

 

 

 

0 Kudos
Message 3 of 10
(351 Views)

I (think I have) followed your example, but I included all of the linear fit code within my while loop where my data acquisition is occurring so that they would occur at the same rate.

 

The issue may be that my data collection is continuous, producing only one value in my array, but I need multiple values to plot and get a fit slope. How can I split up my continuous data collection into distinct points, so that my arrays which go into the Linear Fit Function have more than one active row of data?

 

Thank you!

0 Kudos
Message 4 of 10
(325 Views)

It seems you did not implement my shift registers where the new point is appended to the existing points. (Building an array from one scalar always gives you an array with one element, right?)

0 Kudos
Message 5 of 10
(306 Views)

You need to build an array of points, in order to use the xy graph. 

Your program plot an array with 1 point only. 

 

You need to create a shift register on the sides of the while loop and add every new point into the array , this always growing array you will be able to plot. 

go back to the example with FOR loop example altenbach shared with you and try to implement that in your code. 

 

0 Kudos
Message 6 of 10
(294 Views)

@LVNinja wrote:

You need to build an array of points, in order to use the xy graph. 


In this particular case is is highly preferable to build the X- and a Y-arrays separately (as I showed) in order to maintain good inputs for the linear fit.

 

 (... and if we don't need to fit, building a 1D complex array is preferred over an array of points, IMHO 😄 )

0 Kudos
Message 7 of 10
(290 Views)

I built the shift registers into a for loop, with the code inside. At this point, no values show in my array. Should I build the for loop into or outside the while loop? Also, did I build my arrays and use the shift registers correctly?

 

Thank you!

 

 

0 Kudos
Message 8 of 10
(225 Views)

Hi Charlotte,

 


@charlotte99 wrote:

I built the shift registers into a for loop, with the code inside. At this point, no values show in my array. Should I build the for loop into or outside the while loop? Also, did I build my arrays and use the shift registers correctly?


Not at all…

 

Please speak out loud to yourself: THINK DATAFLOW!

 

Right now you STILL create arrays from a single sample - AFTER the whole DAQ loop has finished.

I guess you want to create an array of samples WHILE the DAQ loop is still running: so where do you need to place your code?

 

I repeat: Please speak out loud to yourself: THINK DATAFLOW! (This is important and no offense.)

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 10
(216 Views)

Hi I posted here the observations on your code. 

LVNinja_0-1729624113828.png

If you want to plot the xy data at the same time as the data acquisition is happening, then you need to implement the shift registers on the same loop as the data acquisition loop. 

At every new data  it has to be added to the previous array from the shift register and being plotted to XY . this array will grow at every iteration.

 

Be mindfull that this solution will grow the shift register at every iteration, it may consume a lot of memory. 

 

LVNinja_3-1729624568063.png

 

 

0 Kudos
Message 10 of 10
(213 Views)