01-25-2017 10:09 AM
Hi, I'm a learning user of LabVIEW. I would like to graph the function y(x)=x*x, but using the values of the slide bar control as x axis in a while loop. I want to graph the y(x) function as a continuous line and a different cursor to highlight the value of the slide bar. I know that using property nodes the maximum and minimum values, as well as the increment of the slide bar can be fixed. However, I haven't found useful examples online. I've attached a screenshot of the desired graph (edited using paint).
Solved! Go to Solution.
01-25-2017 10:17 AM
That looks like two plots on an XY graph to me.
Plot 1:. Line, no points, consists of the calculation of Y's based on a ramp of X's. Data can be calculated once at the beginning of the program.
Plot 2:. Points, no line. Consists of the calculation of a single Y based on the X value in the slide. That data is point is calculated anytime the control changes, and the two plots merged and plotted on the graph. This would be a good use for an event structure acting on the value change event of the slide control.
01-25-2017 10:28 AM
Thanks for your easy to understand explanation. The problem that I'm facing is that the XY graph requires a cluster (cluster or array?) as an input, and I get only one element from the slide control.
01-25-2017 10:49 AM
Look in LabVIEW Help or Examples for XY Graph that tells you a few different ways you can wire data to the XY graph.
If you have a single value that needs to be an array, just use Build Array to create a 1 element 1-D array.
If you need a cluster, use Bundle or Bundle by Name.
If you still get stuck, attach your VI with what you've gotten so far.
01-26-2017 05:47 AM
Thanks, I have some problems trying to merge both graphs, because they are different types of data. It seems a silly problem, but I don't know to figure it out.
01-26-2017 06:20 AM - edited 01-26-2017 06:21 AM
Hi Dranek,
in the first frame you create a cluster of 2 1D-arrays, in the event you create a cluster of 2 scalars. Then you want to build an array of both, which will not work due to different datatypes!
Both plots need to use the same datatype. A XY graph accepts
- (an array of) a cluster of 2 1D arrays
- an array of clusters of 2 scalars
- an array of complex numbers
Did you read the context help of the XY graph? It explains how to build one plot and it shows how to build an array of plots…
Side note: why did you use a sequence structure at all? Everything follows DATAFLOW…
01-26-2017 06:51 AM
See the attached VI.
1. Fixed the data type issue by adding the build array like I talked about.
2. Got rid of the unneeded sequence structure.
3. Replaced the formula node with the X^2 LabVIEW primitive.
4. Added the Ramp pattern function I talked about to create the full curve. (The local variable of the slide did nothing but give you a 1 point curve at whatever value the slide was when the VI started!)
01-26-2017 07:21 AM
Thank you! This example will help me to improve the plotting of my project. I'm trying to plot an instantaneous measurement plus my desired response in the same graph. I know that that I was doing was completely wrong, but it is hard to learn by yourself if you couldn't find examples related to your problem. Thank you for your patience and help!