01-19-2015 09:51 AM
Hey guys,
Background info for context:
I know the answer to this is somewhere out there, but so far I have been unable to enter in the right key words. I am building up an analysis routine where I am comparing monthly values by a category in which there are two "buckets" of information per month. Ultimately, this will all be plotted on a graph to compare month by month values.
Question at hand:
I have built up a 2D array which I want to interpolate much like a 1D array. If I have [x,y] structure where I want to interpolate the second half with the first, what is the quickest way to do this? ie, my values would take the form [0, x/2, 1, x/2+1] while the y values would remain unmixed. (Much like a sort function in Excel where you sort by a single column and every value rearranges based on the sort column.)
I am not a computer scientist, but have tried (probably poorly) to use the proper notation to help convey what I am looking for, but if I have not, please ask and I can clarify. I am hoping to do this in the most efficient manner as these arrays can get very large. I am also a big fan of the MGI, OpenG, GPower, etc. pallets, so if there is something already developed I can use, I am all for it.
Thanks for the help.
Solved! Go to Solution.
01-19-2015 12:48 PM
Well OpenG does have a Sort 2D array. You can sort on rows, or columns and you specify which one. Then the rest of the array is manipulated like Excel.
Also you mentioned 2D interpolation so I thought I'd mention this post, which helps visualize this very well.
http://forums.ni.com/t5/LabVIEW/Interpolating-pixels-in-the-Intensity-Graph/m-p/283031#M149338
And here is the idea exchange on it.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
01-19-2015 03:19 PM
If the number of rows are known at edit time. Use a 1D array of clusters of "Key Value, Value1,...ValueN"
e.g.
01-20-2015 10:48 AM
Thank you so much for the replies guys. I appreciate your thoughts and you answered my question exactly as I had asked it.
I was however very confused by the responses and was trying to interpriate them appropriately. Whelp, turns out I messed up my language in not being a CS. I should have said that I am looking for a method to interleave (not interpolate) the 2D array by row or column. I think I need to split the array in half (remembering in my case that there will always be an even number of indicies), then interleave the rows by there. I can forsee doing it similar to the code below, but I am pretty sure that this is not efficient and doesn't scale well when my arrays get very large.
Any thoughts you have on this design would be greatly appreciated.
(Note: green subVI is OpenG Reorder Array)
01-20-2015 01:01 PM
One approach is pretty much what you're doing, but instead of reordering the original array, maintain the parallel array of indices. Each time you need to access an element of the original array, first look up which element to access using the array of indices. A similar approach is a simple equation to calculate the correct index, instead of using a separate array for that purpose. Depending on how you often you need to access elements of the array, and whether you're accessing subsets of the original array or only individual elements, this might be more efficient.
What are you doing with the data? Is there any chance you can read it into the array in the desired order, instead of rearranging later? I haven't looked inside the OpenG function, but I doubt you'll get much better than that if you actually need the entire rearranged array.
01-21-2015 10:25 PM
01-22-2015 01:56 PM
Alright all, I am going to close this out. I think that I was able to come up with the right implementation for myself, but I appreciate having the sounding board and the support of you guys.
Thanks for the idea and pointing me in the right direction.