LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to "mix" arrays?

Hello
 
again probably a very simple solution:
 
i have several 1D arrays, all of different sizes, that i want to interleave.
Reason: give same priority to elements coming from different subvis, while the output array is treated in row.
Solution i tought best: interleave the array, in such a way that if i have 5 events coming from place A (abcde), and 3 events from place B (123), then the output array would be simply: a,1,b,2,c,3,d,4.
i can probalby create another subvi to do that, but it will consume quite a bit of computation for repeated operation.
I tought "interleave 1D arrays" would work, but it is working by default only with the smallest array size...
is there a way to change this (or another function)?
 
-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 1 of 15
(4,594 Views)
Hi,
there was a discussion before about this here. One solution could look like this:



Greets, Dave

Message Edited by daveTW on 05-23-2007 12:24 PM

Greets, Dave
Message 2 of 15
(4,585 Views)

i had same solution in mind, however it doesnt fit for several reasons:

1) computation time - for repeated operations it is very expensive

2)one creates some 'default' array elements due to the resising.

i was more hoping for an "interleave array" that would be fitting the exact purpose (keeping the blanks out). it seem to me like a usefull function.

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 3 of 15
(4,572 Views)
Are you resizing this array on the fly or operating from a fixed array size (your intended 1D output array?) How many times do you see this function happening?  The issue here is that you are creating a memory leak if you are going to run this over days, weeks and months.  If you want to reduce computational times, then fixing the size of the arrays will drastically speed up these repeatative operations.  Where does the output of the 1d array go? 

Paul
0 Kudos
Message 4 of 15
(4,563 Views)
Hi Stradis,
 
i have long tought of using fixed array size, but i discovered that the only size i can use is: single element !! the reason is that if my array included some empty elements, my system cannot differentiate them form "real data" withtout another computation stage, which is very time consuming.
i create arrays of various size ,ranging from 1- to few Mega elements. they are then sent out to further operation in a time critical system, while a next chunk of such arrays are created. all in all i create per cycle about 500 -2000 chunks, for a total of about 100 -300 Mega elements (I32).
 
i understand the memory leak problem, and will see if this is going to be critical to me.
-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 5 of 15
(4,555 Views)
I'm a little confused. It seems you want to compute something without actually having to do any extra computation due to timing constraints. That, of course, will never be possible in LabVIEW! 🙂

If you do design a subVI to do this work for you, one way to help minimize the overhead of calling it repeatedly is to set its Execution priority to subroutine. This virtually eliminates the overhead of calling it as a subVI. You can't do everything in subroutines. For instance, you can't use functions that have timeouts such as queues, or functions that force a switch to the User Interface thread such as VI Server property nodes or invoke nodes. But simple array manipulation is perfectly acceptable.

The standard way to deal with fixed size arrays that contain variably sized data is to have a numeric offset that indicates the last valid data point, or perhaps an array of these offsets to distinguish interleaved data. Having fixed-size arrays will greatly increase execution speed if you get it right, because memory allocation can be very slow (the memory manager is a shared resource).

What I would suggest is that you post an interleaving subVI design idea that does what you want, but doesn't meet your performance needs. Then some of us here can help fine tune it until it does its job more efficiently.
Jarrod S.
National Instruments
Message 6 of 15
(4,544 Views)


@Gabi1 wrote:
Solution i tought best: interleave the array, in such a way that if i have 5 events coming from place A (abcde), and 3 events from place B (123), then the output array would be simply: a,1,b,2,c,3,d,4.

Sorry, I don't understand your desired algoritm at all. 😮

 Looking at the output...

  • What happened to element "e". Did you just throw it out?
  • Where did element "4" come from? Did it just appear out of thin air?


0 Kudos
Message 7 of 15
(4,529 Views)

Sorry about that Christian,

that is what happens when there is only 24 hours per day, and one works in all of them... 🙂

i was meaning a, 1, b, 2, c, 3, d, e,

 

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 8 of 15
(4,485 Views)
Jarrod,
 
thanks for the ideas. i was hoping for an "interleave" that indeed would be faster than my subvi. you see, if i would use C++, then i would have pointers to those arrays, and directly pick up data from each one in a row, not having to bother to interleave or check if array full or empty.  there would be virtually no addition of memory, nor actual computation. that is what i am looking for creating using labview.
for the mean time i have decided not to interleave, and see where it will lead, hoping priority issues will be minimal.
 
 
-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 9 of 15
(4,482 Views)

Before I spend time working up an Action Engine to do this...

Have you concidered using a Queue or multiples?

The producers would feed the que and the single consumer would pull them out in order.

With multiple queues the consumer could check each que in turn and effectively do the mixing on the fly.

The queues will operate in-place.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 10 of 15
(4,471 Views)