LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Update XY Graph during Nested For Loops

Solved!
Go to solution

I am trying to update an XY Graph in each iteration of a "For Loop". The only way i can get it to somewhat work is if I place the graph outside my loops and tunnel the data thru. If i place the graph inside the inner loop, it will plot the first iteration, then clear graph, then plot 2nd iteration and so on. I want the graph to plot and update on every iteration ... any ideas ?

 

 

NestedFORLoop.png

0 Kudos
Message 1 of 11
(3,184 Views)

The way that graphs work, they clear all previous data and update with the most recent array.  You may be looking for a chart if youd like to update inside a for loop.  The chart will accept an element data and update the existing data every iteration.  Charts have an adjustable history length that can be used to change the displayed length of data and to also limit memory consumption when using a chart.



-Matt
0 Kudos
Message 2 of 11
(3,177 Views)

So if i change my XY Graph to a Waveform Chart , what do i use to convert my bundle to a Wave Chart datatype ? Error.png

0 Kudos
Message 3 of 11
(3,170 Views)

If you data is a function of time, look at the Nugget by Crossrulz found here that talks about a waveform chart.

 

If you data is NOT time dependant...

 

Since there is no such thing as a XY chart, you would have to use shift registers to keep your history data from iteration to iteration and append the updates in the inner loop.

 

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 11
(3,166 Views)

(sorry, posting by phone).

You simply need to substitute an explicit "build array" for the graphs and keep the array of plots in another set of shift register, eliminating the autoindex in you currently have.

Yes, since your x are spaced equally, all you need is a plain waveform graph. Also, since you know the final size of the data structure, initialize it before the loop filled with NaN (they don't graph) and substitute real data as it arrives.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 5 of 11
(3,147 Views)

Assuming your x values are actually not equally spaced and the data structures are relatively small, here's a nearly literal upgrade of your code (If the data structures are large, go with the NaN preallocation and replacment with real data as mentioned).

Currently, it updates with each new point in the innermost loop. If you only want to update in the outer loop, place the indicator and "built array" there instead and keep the inner loop all orange.

 

 

 

I would also recommend complex 1D arrays for xy graph. Keeps the diagram simpler.

 

 


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Download All
0 Kudos
Message 6 of 11
(3,127 Views)

I appreciate that AltenBach, thats closer to what I need. I guesss I should try and explain a bit more ... 

 

I have some RF Test Equipment and am sweeping from 2GHz to 10GHz in 1GHz increments and recording the output power at set intervals. So my x-axis is my time "points" in intervals beginning at 0, and my y-axis is my output power levels at each frequency point. So my Frequency starts at 2GHz, waits the interval and then records a power, changes to 3Ghz , waits the interval and records, and so on ... Filling in the Data table goes from left to right, top to bottom , this is where i am having issues populating my Graph. I will get one datapoint on each frequency, then it cycles to start over @ 2 GHz ... 

 

 


DataTable.png

DataGraph.png

0 Kudos
Message 7 of 11
(3,100 Views)

OK, so I would initialize a final xy graph data structure (e.g. correctly sized 1D array of clusters, each containing a complex 1D array of the right size, all containing NaN). Place it inside a shift registers of the loop. Now you can replace with real data at any desired position at any time and fill them in any order.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 8 of 11
(3,095 Views)

you  lost me ... but i will see what i can do , appreciate it

0 Kudos
Message 9 of 11
(3,086 Views)
Solution
Accepted by topic author gingram536

maybe like this?

 


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 10 of 11
(3,072 Views)