LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Access to cluster/object data in array

Hello,

 I have some question:

 Is there an  elegant way to do the next::

  Suppose we have a cluster/object that contains two elements,say "NUMBER" and "BOOL".Now we create an array of this cluster/object.
Now,I want to get an array of "NUMBER" from array of cluster.Is it possible without loops?

Thanks,
Michael Shklyar
_________________________________________________________________________________________________
LV 8.2 at Windows & Linux


0 Kudos
Message 1 of 13
(3,228 Views)

Hi Michael,

Technically speaking yes it is possible but there are limitations to any appraoch that does not use loops.

Rather than wonder down that path, could you please post

an example of your "in" (the array of clusters) and your desired "out" (array indicator)

and could you tell us a bit more about why you wnat to do this without loops.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 13
(3,216 Views)
Hello Ben,

 Thanks for your answer,I attach the VI.
About the reason not to use loops: for elegancy, and easy data access.

 Thanks,
  Michael.
_________________________________________________________________________________________________
LV 8.2 at Windows & Linux


0 Kudos
Message 3 of 13
(3,212 Views)

NO-GO for arrays or arbitrary size!

ASide from using an unbundle by name rather the plain "unbundle" they way you coded is acceptable.

Rather than just give up this could you tell us more about what is "in-elegant" about what you posted?

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 13
(3,203 Views)
if you are doing this to minimize passing wires, then a cluster of two arrays maybe a better approach.  When I am frequently indexing and unbundling to get at the specific information constantly, I have to reevaluate my delivery package thinking of the datasink instead of the datasource.  I think either you use a 1 or a 0 for true or false and a 2d array or just use two arrays, and put them in a cluster if wirespace is a concern.   To that end, I would typedef that cluster so if you make changes as time goes on, you do not have to update every instance by hand.

Paul
0 Kudos
Message 5 of 13
(3,196 Views)
Hi Ben,

 The in-elegant here,as I see it is the time of execution.In the example that was posted,we should run thru all array.
The solution that I was looking for,is Rearranging the data handling,as LabView  "sees it",and not Creating new data.

 Thanks,
 Michael.

Message Edited by mishklyar on 09-12-2007 09:01 AM

_________________________________________________________________________________________________
LV 8.2 at Windows & Linux


0 Kudos
Message 6 of 13
(3,195 Views)

Thank you for the clarification Michael.

In this thread Shane and I discuss over the course of a week some of the fine points with working with arrays of clusters.

Please review that thread to get an idea of what it takes to work with arrys of clusters.

The important things to note are;

1) Memory allocation is an expensive operation. Do it as infrequently as possible.

2) The show buffer allocations gives you a view of when memory is being allocated.

I hope this help!

Ben

PS: Christian, this Q is right up your alley.  Smiley Wink

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 13
(3,173 Views)


@mishklyar wrote:
 The in-elegant here,as I see it is the time of execution.In the example that was posted,we should run thru all array.
The solution that I was looking for,is Rearranging the data handling,as LabView  "sees it",and not Creating new data.

Your solution is actually very elegant and very efficient. A FOR loop is not a problem! It is one of the fastest structures and due to the use of autoindexing, all outputs can be fully allocated in one swoop.

You cannot reintrepret the data in memory, because the flattened representations between your two clusters is different. No matter what, a copy needs to be made.

If you would refactor your code from ground up, maybe you can stick with a single data representation so you don't need to reshuffle.

Message 8 of 13
(3,164 Views)

OK, looking at the code once more, you don't need to initialize the first array, because all elements are the same. Here's a version that does NOT need to allocate the initial array.

Message Edited by altenbach on 09-12-2007 10:36 AM

Download All
Message 9 of 13
(3,160 Views)
Using Initialize Array for the DBL part is slightly faster, 5.07 vs 6.19 us over 1000000 repetitions. Unfortunately, Initialize array does not work with array data types.

Lynn
0 Kudos
Message 10 of 13
(3,150 Views)