10-17-2024 09:39 AM
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!
10-17-2024 10:01 AM
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).
10-17-2024 10:21 AM
Assuming you want to fit while data is acquired, see if this can give you some ideas....
10-17-2024 01:16 PM
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!
10-17-2024 02:26 PM
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?)
10-17-2024 04:55 PM
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.
10-17-2024 05:20 PM
@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 😄 )
10-22-2024 01:44 PM
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!
10-22-2024 02:16 PM
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.)
10-22-2024 02:18 PM
Hi I posted here the observations on your code.
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.