11-29-2010 03:35 AM
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.
11-29-2010 08:50 AM
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
11-29-2010 09:58 AM
...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
11-30-2010 03:22 AM
thank you both! problem solved 🙂
11-30-2010 03:45 AM
@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. 😉
11-30-2010 03:51 AM
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.
11-30-2010 08:31 AM
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.
11-30-2010 11:51 AM
@ altenbach : 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" )
11-30-2010 01:21 PM - edited 11-30-2010 01:23 PM
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.)
11-30-2010 01:42 PM
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.