LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reshuffle / Interleave 2D Array

Solved!
Go to solution

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.

B Sampson
Ceres Bio Fuels
Message 1 of 7
(5,765 Views)

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.

 

http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Interpolate-array-for-higher-dimensions-bilinear-trili...

Message 2 of 7
(5,743 Views)

If the number of rows are known at edit time. Use a 1D array of clusters of "Key Value, Value1,...ValueN"  

e.g. Capture.PNG


"Should be" isn't "Is" -Jay
Message 3 of 7
(5,725 Views)
Solution
Accepted by topic author BSampson

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.

 

2D interleave.png

(Note: green subVI is OpenG Reorder Array)

 

 

B Sampson
Ceres Bio Fuels
Message 4 of 7
(5,684 Views)

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.

Message 5 of 7
(5,664 Views)
Thanks for the thoughts nathand. Your approach makes the most sense, but I think it's a little beyond me to implement properly. (Your approach would be akin to pulling data by pointers, correct?)

To answer your question, I am working on building up a plot of our runs. Everything passes or doesn't which gets multiplied by a cost of failure or gross margin. Add the data with a tag for product and a month for pass or fail and I can bin everything properly.

I am trying to plot the data on a waveform graph, as it seems the easiest to structure my data with, but am running into some issues with property nodes to format it like I wamt. I'll likely post something on that in another thread if my experimentation doesn't go anywhere.

Thanks again for the input.
B Sampson
Ceres Bio Fuels
Message 6 of 7
(5,631 Views)

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.

B Sampson
Ceres Bio Fuels
Message 7 of 7
(5,600 Views)