12-12-2016 11:49 AM
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 ?
Solved! Go to Solution.
12-12-2016 11:59 AM
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.
12-12-2016 12:22 PM
So if i change my XY Graph to a Waveform Chart , what do i use to convert my bundle to a Wave Chart datatype ?
12-12-2016 12:29 PM
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
12-12-2016 01:05 PM - edited 12-12-2016 01:15 PM
(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.
12-12-2016 01:30 PM - edited 12-12-2016 01:31 PM
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.
12-12-2016 02:44 PM
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 ...
12-12-2016 02:55 PM
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.
12-12-2016 03:10 PM
you lost me ... but i will see what i can do , appreciate it
12-12-2016 03:29 PM - edited 12-12-2016 03:46 PM