LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

array from XY graph

Solved!
Go to solution

Hello everyone.
I need to create an array with n values from xy graph. The values of the array should be the y values from a certain range that I want to choose from the x-axis. For example, create an array with 1000 y values of the graph in the range of 20 to 500000 (of the x-axis).

0 Kudos
Message 1 of 12
(2,105 Views)

You can read the Value property of the graph to get the full dataset, then possibly sort (if the points are out of order, and optionally adding an index if you need them back in the order they start afterwards), and then use Threshold 1D Array to find the index at which your X points are inside the range you want.

 

Then take those points' y values, and do decimation if required. 

 

You will possibly also need various datatype manipulations (unbundling, autoindexed For loops, etc) depending on how your graph data is stored.


GCentral
0 Kudos
Message 2 of 12
(2,076 Views)

If you have the data that were used to create the Graph (that is, if you have a LabVIEW program that runs and creates the Graph), it should be simple to sort the Array according to the X value and "extract" the X-Y pairs that lie within your selected X Range.  Why don't you try writing such a program and come back here, posting your LabVIEW code (i.e. attach a file with the .vi extension, not a "picture") if you have problems getting your code to work?

 

If all you have is a "picture", it will be a more difficult (and definitely "messier") problem.

 

Bob Schor

0 Kudos
Message 3 of 12
(2,075 Views)

I need to create an array of 1000 y values that are in the range of 2E+7 to 5E+8. The goal is to change the size of the arrays in the JigOffsetFile.csv file to 1000 values that are in the frequency range between 20MHz and 500MHz and still maintain a balance between the values of the 2 arrays.

Download All
0 Kudos
Message 4 of 12
(2,064 Views)

Your data file appears to be sorted.  LabVIEW can easily read this using "Read Delimited Spreadsheet".  Note that if you do a little extra work, you can get "Read Delimited Spreadsheet" to skip the first row of header characters and read all of the data as a 2D Array of Dbl, so you won't have to deal with strings.

 

The Arrays are (conveniently) already sorted, so I can see that you have about 1323 entries that fall in your frequency range.  I don't understand what you mean (nor wish to do) by "maintain a balance between the values of the two arrays".  Where's the second array?  [You aren't considering the 2-D Array of Frequency and Offset as two 1-D Arrays, "Frequency" and "Offset", are you?  That would be silly, in my opinion ...].

 

Bob Schor

0 Kudos
Message 5 of 12
(2,061 Views)
  • Simply read your file once into a 2D array With 2 columns and N rows. (toss the first row because it contains you header).
  • Delete from array is not the correct function to take an array subset (hint ;)).
  • Autoindex the 2D array on a FOR loop and use a conditional output tunnel that keeps each row if the first element is within range.
  • Graph it.

 

0 Kudos
Message 6 of 12
(2,048 Views)

@nonish wrote:

I need to create an array of 1000 y values that are in the range of 2E+7 to 5E+8. The goal is to change the size of the arrays in the JigOffsetFile.csv file to 1000 values that are in the frequency range between 20MHz and 500MHz and still maintain a balance between the values of the 2 arrays.


You have an overloaded goal here. You can either have 1000 value starting with x=2e7, or you can have all values in the range 2e7 to 5e8 (1325 point in your case), but not both conditions unless you remap the data by interpolation. Do you want to do that instead?

 

Here's what I had in mind earlier (note that the header drops out anyway because it defaults to zero, i.e. out of range)

 

altenbach_0-1617380058718.png

 

As others have already said, a graph is an indicator, not a data source. You need to operate on the data going to the graph.

You really (really!) need to do a few simple lessons on array operations. Start here.

0 Kudos
Message 7 of 12
(2,040 Views)
Solution
Accepted by topic author nonish

@altenbach wrote:
You have an overloaded goal here. You can either have 1000 value starting with x=2e7, or you can have all values in the range 2e7 to 5e8 (1325 point in your case), but not both conditions unless you remap the data by interpolation. Do you want to do that instead?

If you want exactly 1000 equally spaced interpolated points in your range (assuming the original x values are nondescending!), here's all you need to do:

 

altenbach_0-1617381903356.png

 

And since the x-values are now guaranteed to be equally spaced, a plain waveform graph is all you need, to graph dB. Just set x0 and dx of the x axis according to the ramp.

 

0 Kudos
Message 8 of 12
(2,028 Views)

Great solution. Thank you.

0 Kudos
Message 9 of 12
(1,982 Views)

Thanks. Yes, I wanted to remap the data by interpolation, and I already got a solution.

0 Kudos
Message 10 of 12
(1,957 Views)