04-02-2021 06:57 AM
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).
Solved! Go to Solution.
04-02-2021 07:31 AM
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.
04-02-2021 07:33 AM
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
04-02-2021 07:56 AM
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.
04-02-2021 08:53 AM
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
04-02-2021 10:56 AM
04-02-2021 11:18 AM - edited 04-02-2021 11:35 AM
@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)
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.
04-02-2021 11:46 AM - edited 04-02-2021 12:20 PM
@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:
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.
04-04-2021 06:43 AM
Great solution. Thank you.
04-04-2021 06:51 AM
Thanks. Yes, I wanted to remap the data by interpolation, and I already got a solution.