03-18-2011 06:43 AM - edited 03-18-2011 06:47 AM
Hi
I am new to LabVIEW. For my degree course, i have to create a graph of load on a beam against the voltage reading from a rosette strain gauge.
I have managed to create the table required, and i can export it to Microsoft Excel to create the graph there, and that works fine. However, ideally, i would like to just use LabVIEW to create the graph.
Attached is an example of the table after the test is run. [table1]
from this table i need to plot 3 lines (A,B,C) on a single graph of voltage(y-axis) against load(x-axis), with a line of best fit for each one.
Also attached is an example of the graph created on excel, to give an idea of what i'm trying to create. [graph1]
Any help would be much appreciated, as i am new to using Labview.
Thanks
Solved! Go to Solution.
03-18-2011 07:11 AM
Create an X array with the values (2;4;6;8;10)
Bundle your X-array to your first Y-array(1st column)
Bundle your X-array to your second Y-array(2nd column)
Bundle your X-array to your Third Y-array(3rd column)
Connect these three to a build array
Connect the output of the build array to your XY graph
More info can be found here , example
X-Array Y-Array Definition:
You can define a plot as a cluster that contains an array of x coordinates and an array of y coordinates. Build an array of such clusters to define a multi-plot XY Graph.
03-18-2011 07:14 AM - edited 03-18-2011 07:16 AM
Here are some hints to get you going...
Treat the table as an array. By using 'index array' you can access individual elements, or more usefully whole columns or rows.
The information in your table is probably in string format. Have a play with the String/Number conversion functions to convert the text into numbers.
Using these two bits of info should get your data in the right format to feed into a graph.
Graphs take arrays of data bundled together as X-data and Y-data.
If your data is starting off as a 'number' before turning into text inside the table, you could bypass the conversion by feeding it straight into the graph?
Thats a couple of ideas to be going on with, post back once you've had a go.
Ian
EDIT: Looks like Bjorn got in whilst I was still typing, still theres two sets of info for you.
03-18-2011 07:54 AM
Thank you both so much for your help. I have managed to build the graph required, but the only way i can figure out how to do it is by using number controls in each array and entering the values from the table individually.
This gave the right graph, but is there a way i can seperate the 3 columns of data and put them into each of the Y-arrays?
I think using the index array suggested by Ian would work, but how can i get the required column?
thanks again for your help
Luke
03-18-2011 07:57 AM
Use "index array" and wire a constant to the index. 0=first column ; 1= second column
You can use string in your table, but you have to convert the array to numbers by using the VI "string to number"
you don't have to do them one by one, you can wire an array as input
03-18-2011 08:01 AM - edited 03-18-2011 08:03 AM
As an example, see the attached.
The index array function lets you get at an entire colum (or row) by leaving one of the inputs unwired.
To get more than one column at a time, click and drag the bottom of the icon downwards to access more terminals.
EDIT: Doh, Bjorn got in there already again.
03-18-2011 08:56 AM - edited 03-18-2011 08:58 AM
please find attached my vi
I can;t see why it is giving me an error. I tried the string to number conversions between the index array and the different bundles, but it gave errors each time. I tried it without and it is still giving me an error.
Thanks for your help
Although the table is empty, i have tried it with my data and the error is still there
03-18-2011 09:32 AM
See the attached where I've wired up a string conversion to each string array.
I can't test it with your data as no default values are present, however it seems to work OK.
Is that what you needed?
Ian
03-18-2011 09:41 AM
I managed to figure out what i'd done wrong. I was just in the process of posting this when you posted your response Ian.
Thank you Ian and Bjorn for both your help. It is greatly appreciated
Luke
03-18-2011 09:47 AM
Not sure how you've implemented it, but putting the conversion before the index array probably makes more sense that the previous version I posted:
PS Its generally more helpful for people with similar problems in the future if you mark the post that solved your problem as the solution, not a post which doesn't show the solution