09-14-2011 02:33 PM - edited 09-14-2011 02:42 PM
Hello,
I have a graph with a fixed X-axis and an array of Y values which varies. How do I plot these new y values without replacing the previous ones? E.g to have a scatter of new data? Example of shown in Figure 1 below:
Figure 1: (Note: image was photoshopped to demonstrate goal)
Figure 2: Current block diagram, LabVIEW VI:
Thank you!
Solved! Go to Solution.
09-14-2011 03:12 PM
See attached. (You need to duplicate your X values fed into the cluster.)
09-14-2011 03:27 PM
Thanks Skydyvr. I think duplicating the constant (x axis) is tricky, because I would need a duplicate for every run. The runs are variable and bring in the new y-axis data. Please let me know if you have an alternative approach, i would greatly appreciate it, thanks 🙂
09-14-2011 03:36 PM
The obvious come to mind of just adding another plot for every run.
I don't think it would be that tricky. Because if you want to keep the data on just one plot, you would need to insert the new data points into your "new data array" anyway. You know what index you are inserting the new data points at. So you know the index to insert a duplicate X axis point also.
Actually I just tried this and it works. You can also add the new values to the end of the Y array. At the same time you add the X values to the end of the X array. This way you are not inserting elements into the array. Just adding new elements to the end of the array.
09-14-2011 04:10 PM - edited 09-14-2011 04:16 PM
Skydyvr, thanks again. However, I dont believe I follow. Im planning to use index 0 to 8 for my X-axis. Ive tried buliding a third for loop to place new x values with every new y value, but still no luck. Meaning I get new Y values, X-axis stays the same, but the data points dont accumulate, the graph only shows the most recent plot. Please demonstrate using a picture/VI, thanks.
09-14-2011 04:21 PM
Just build up a single plot:
09-14-2011 04:23 PM - edited 09-14-2011 04:24 PM
.
09-14-2011 04:25 PM
Think about what you are really building. You are building an array of clusters, right? For each element in the array you have a cluster whos content has a value for the X axis and a value for the Y axis. As long as you are not connecting the datapoints in the graph (which you aren't), you can plot the datapoints in any order. If you are building your X portion of the cluster seperately than your Y portion of the cluster, you just have to make sure the indexes do not get transposed somehow.
Build the lower half of the attached picture, and you will see what I mean. (hopefully):smileywink:
09-14-2011 05:00 PM
Darin, that works like a charm, please clarify why you used the Re/Im to Complex node or how it generally plays into the overall result.
PS: Thank you both for all your help! 🙂
09-14-2011 05:26 PM
LV stores a complex number (say double) and a cluster of two doubles in exactly the same way. You can Type Cast seamlessly between the two, and the XY Graph is happy to graph them. I use it here simply because a 1D array of Complex Double is easier to deal with the corresponding 1D array of clusters.