LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Extracting information about specific array element

Hello Everyone,

I have a 16*14 array, changing every second, with some I32 values and I want to know with each iteration if there is a change in any of the elements.

If the number of changes are bigger than 10 there should be a msg including the overall difference in the exact element that produced more than 10 errors. So I subtract my array with the previous one, using feedback node and I add the resulting array to itself. I can check if there is a value inside the last array greater than 10 but I can not figure out how to know what column and row the element is.
If anyone could help I would appreciate it.

0 Kudos
Message 1 of 14
(3,200 Views)

Your description is not very clear.

 

Do you want to find all elements of the array where the new value is greater than the old value by 10 or more?  If so, the comparison functions should work for you.

 

Lynn

 

Compare arrays.png

0 Kudos
Message 2 of 14
(3,169 Views)

...and if you wnat to know which elements are different then use a "not Equal" teh output will be an array of the same size as the arrys being compared and then use reshape array to cast as a 1d aray and then use a search 1d array on that 1d array looking for a True. Repeat the search start at teh index of the previous found plus 1 to find other changed values.

 

Ben

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

thank you both! problem solved 🙂

0 Kudos
Message 4 of 14
(3,132 Views)

 


@Eleftherios wrote:

If the number of changes are bigger than 10 there should be a msg including the overall difference in the exact element that produced more than 10 errors.


 

What happens if more than one element changed by more than 10 and both changed by the same amount. Now you have more than one set of coordinates.

 

If you are only interested in the biggest change, subtract the current 2D array from the previous 2D array, take the absolute value, then use "array min&max."

Compare to see if the max value is lager than 10, and if so, get the index of the max value from the output right below the max value output. These are the "coordinates". No reshaping and searching needed. 😉

0 Kudos
Message 5 of 14
(3,126 Views)

i am interested in all elements that changed more than 10. which i will be saving into an array because these elements correspond to another array from which i
have to generate a file saying that these elements exceeded 10 errors and reached, this value.

 

here is an example.

0 Kudos
Message 6 of 14
(3,121 Views)

Can you attach the actual VI?

 

It looks overly complicated. Remember, whenever you have "index array" exclusively wired to various [i]'s, you can eliminate "index array" and use autoindexing at the loop boundaries. Now the code scales automatically and you don't even need (or should!) wire N.

 

OTOH, you might also want to check that things really operate "in place", especially the lower 2D array. This is difficult to tell for the current code. Maybe use shift registers at the loop boundaries instead of an external feedback node to make sure.

0 Kudos
Message 7 of 14
(3,108 Views)

@ : about the shift registers i had the same idea ( almost ).

feel free to make changes if they are for the best 🙂 ( i do not fully understand what you mean when saying "not connecting the N" )

0 Kudos
Message 8 of 14
(3,093 Views)

When you use autoindexing, N is automatically determined from the dimensions of the array. here's a fragment how your code could look like in the upper left.

 

 

Now the code does not need to change at all if you need to use it on a bigger or smaller 2D array in the future. Scalable code!

 

(Can you explain the "avoiding overflow" logic. Makes no sense to me.)

0 Kudos
Message 9 of 14
(3,078 Views)

I think some of your problems is the init of the feedback nodes in the sub VI.

Each time it is ALWAYS initialized to InputArray so the two array will always be equal.

Plus the SumOfErrors feedback is ALWAYS an EMPTY array.

 

I also do not understand the Overflow. If not for this you could do the checking without any loops and work on the whole arrays instead of at the element level.

Omar
0 Kudos
Message 10 of 14
(3,069 Views)