LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Delete Repeated Rows in 2D Array taking in cout only one element.

Solved!
Go to solution

Good Morning

I know my question is weird but I'll try to explain I have a 2D array where I need to delete rows only taking in count one element, and with the rest of the elements get an average and keep this dat6a in the new array.

I attach the snippet of my code and a image eplaining what I trying to do.

 

Greetings from Mexico

Download All
0 Kudos
Message 1 of 10
(3,652 Views)

All you probably need is a single loop. Do you want to average rows or columns?

 

(Sorry, posting by phone)

0 Kudos
Message 2 of 10
(3,627 Views)
Solution
Accepted by jalex0906

Since your snippet showed 2017, I've attached a fairly ugly 2017 solution.

If you have access to 2019, you can use a map from double to array of doubles, and massively simplify the code 🙂

Indeed, you can check Christian Altenbach's (poster above) presentation at NI Week for information about Variant Attribute to Map comparisons!

 

Here's a slightly tidied version (attached as v2) for reading without LabVIEW.

snippet.png

Unfortunately, Varriant Attributes won't add a new attribute if it doesn't exist using the Get/Set In-Place structure, so you need that case structure afterwards.

Using the Map(DBL, DBL[]), you can set the behaviour to "Modify or Add" (or similar phrasing) to avoid the need for the CS.

 


GCentral
Download All
Message 3 of 10
(3,620 Views)

Hi the average will be the columns

0 Kudos
Message 4 of 10
(3,613 Views)

Muchas Gracias (meaning Thanks in Spanish) cbutcher, I tried the code and it works great!!! Now I'm examinating the block diagram to attach to a bigger code.

0 Kudos
Message 5 of 10
(3,602 Views)

@jalex0906 wrote:

I know my question is weird but I'll try to explain I have a 2D array where I need to delete rows only taking in count one element, and with the rest of the elements get an average and keep this dat6a in the new array.

I attach the snippet of my code and a image eplaining what I trying to do.

 


OK, whatever you are describing has little to do with the code you are showing (which makes no sense anyway)..

What do you mean by "taking in count one element"? Which element? The first column? User sepcified?

So you want to average all columns that have a "2" as first element? Your example only contains "2s" in the first column. Is this normal or are there also other possibilities?

 

When attaching a snippet, it helps if the input array contains typical default data. It also helps if the default data is not degenerate. If there can be otehr elements beside "2" in the first column, that should be part of the example data.

 

0 Kudos
Message 6 of 10
(3,599 Views)

Here's what I had in mind, but maybe I don't understand your problem correctly. (The FALSE case is just wired across)

 

averagepartialcolumns.png

Message 7 of 10
(3,592 Views)

And if you want an average for all unique elements in the first column, here's what you could do. Maybe this can give you some ideas.... (Of course you need to remember that DBL comparisons might be dangerous, depending on where the data comes from)

 

AverageColumnsByFirstElement.png

 

 

Message 8 of 10
(3,582 Views)

That is great...In my case my data comes out of DAQ Device 

0 Kudos
Message 9 of 10
(3,568 Views)

For comparison, here's how my last code would look like using a map (only LabVIEW 2019+). Much less obscure than the variant attribute method. 😄 Same result. 😉

 

AverageColumnsByFirstElementMap.png

0 Kudos
Message 10 of 10
(3,490 Views)