LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array manipulation in LabVIEW

Solved!
Go to solution

Hi,

 

I'm currently doing a LabVIEW software to track flies.

 

I would to manipulate arrays, but I'm not able to do it, it's too complicated for me.

 

To explain it, I thought the best way was to make an example of it in excel, but I confirm that I'm working in LabVIEW with arrays.

 

LabVIEW-Array-Help.png

 

I'm just lost in that array manipulating.

 

I hope my example is enough clear, it's really hard to explain it, even by oral.

 

Thank you,

Sébastien

0 Kudos
Message 1 of 11
(5,504 Views)

If you have zeros in the other columns, you can add alternative columns (columns 0,2,4) and then check if any of the elements in the added array is zero. If it is, fetch the corresponsing value using the index from the center array and replace the zero. This will give you X array, do the same for columns (1,3,5).

Hope that makes sense!


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
Message 2 of 11
(5,476 Views)

For each Fly, create four 2D arrays (Up, Right, Left, Center.) Use a For Loop to compare each row of the arrays with (0,0). Choose the row that is not equal to (0,0) and output that row to a new 2D array (Fly).

 

This requires that all 4 arrays are of the same size. Use those same comparisons for the Was In? column.

 

You can then combine all the arrays together, or sort/filter however you want.

 

 

National Instruments
LabVIEW
Certified Developer
Message 3 of 11
(5,469 Views)

Thank you,

I'll check this on Monday at work 🙂

 

Did you notice that a fly can be in RIGHT Zone and CENTER Zone at the same time? but In that case, I want to keep only the Right Zone coordinates?

EDIT : Reading once again your code, I feel like yeah, you were aware of it; thanks!

0 Kudos
Message 4 of 11
(5,453 Views)

Here is some simple code dealing with one fly. It would be trivial to add an outer loop to iterate over all files present.

 

 

Right now it assumes that all data is valid (e.g. "no row is all zeroes")

 

 

Message 5 of 11
(5,419 Views)

ArrayManipulation.png

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 6 of 11
(5,413 Views)
Solution
Accepted by topic author Zepiii

Assuming that the input is a numeric array with 8N columns for N flies, here's how you could handle it.

 

 

Download All
Message 7 of 11
(5,404 Views)

To everyone,

 

Thank you very much for you help. This forum is so helpful for me, that I'll thank it in my thesis. The Vision forum part is way less inactive, sadly.

 

The altenbach solution was the best in my case!

 

@altenbach : Right now it assumes that all data is valid (e.g. "no row is all zeroes")


About this, it can happen that fly disapear if a setting isn't correctly set or for an other reason, so sometimes, it may happen. If it's annoying me; I'll probably remove all the 0 rows for the array before applying your VI (which is know a subVI of my program!); but I think I'm able to do it alone.

 

Thank you very much.

Problem solved for me 🙂

0 Kudos
Message 8 of 11
(5,340 Views)

Zepiii wrote:

@altenbach : Right now it assumes that all data is valid (e.g. "no row is all zeroes")


About this, it can happen that fly disapear if a setting isn't correctly set or for an other reason, so sometimes, it may happen. If it's annoying me; I'll probably remove all the 0 rows for the array before applying your VI (which is know a subVI of my program!); but I think I'm able to do it alone.


You can place a case structure in the middle FOR loop, containing the current formatting and array building in the true case. In the false case, place a string array containing [-1, -1, disappeared] ot similar. Wire the output going to the conditional terminal in the innermost loop to the case selector (turn off autoindexing at the inner loop boundary).

 

Here's a quick modification ....

 

Download All
Message 9 of 11
(5,320 Views)

Hi,

 

Is this removing the 0-0 line OR replacing the XY by - - and the "was in?" by GONE!?

Because in my case, if the coordinates is 0 0 in UP, LEFT, RIGHT AND CENTER, then it's a bug, so I would prefer it ignore that line.

However I feel the easiest is to remove it before starting this VI, no ?

 

But don't worry too much, I'm not there yet and I may not encounter that problem.

 

Thank you,

Zepiii

0 Kudos
Message 10 of 11
(5,308 Views)