08-03-2017 06:01 AM - edited 08-03-2017 06:04 AM
@IanSH: i have no coordinates, just indices per row (for the first example) with the "error" of added "0"s because of the array shape
08-03-2017 06:07 AM
@stuleo wrote:
Thanks! I am just discoverying all the nice features of LabVIEW and they are many! I wasn't aware of what concatenating was doing, now it makes sense and it actually looks a lot nicer. I think I did the same in my case by including the if structure to take these in an order. Now, my question goes a little further but I wouldn't like to open another post since we are all on the same page here. If you think I should, please let me know. I want to make a subarray of my elements whose indices are included inside the boarders of the indices I just extracted. I will try some things of my own but I would appreciate any suggestions.
i am not sure i understand correctly:
from your 2D input array you want a 2D subarray,
that has "borders" defined by the found indices?
in my exmple above it would be the same, because "2" is in the first column, in the last column and in every row?
08-03-2017 07:41 AM - edited 08-03-2017 07:43 AM
since noone yet ....
quick and "dirty" ... i suppose altenbach flies in in a second and produces a magic micro vi using variants 😉
:cheers:
08-03-2017 08:10 AM
Working method using my original index search then using that information:
The code in previous post doesn't handle having the extra 2 that I replaced at point 28. The general approach of finding the first instance from each side (I guess thats what's being tried) is a reasonable approach.
08-03-2017 08:14 AM - edited 08-03-2017 08:15 AM
with IanSh's method:
EDIT: hehe .. you beat me to it 😉
08-03-2017 08:21 AM - edited 08-03-2017 08:26 AM
@IanSh wrote:
The code in previous post doesn't handle having the extra 2 that I replaced at point 28. The general approach of finding the first instance from each side (I guess thats what's being tried) is a reasonable approach.
mhh works for me with your DATA, i don't see the error
EDIT: yikes .. found it 😉 -- problem seems the 22 position, have to fix
08-03-2017 09:16 AM - edited 08-03-2017 09:19 AM
fixed it ..
@IanSh: thx for pointing out the error
regarding the efficiency: if there is only one occurrence of "to find" in the row, all elements will be compared, only if at least two are present, then this solution is faster.
the amount of compares saved should be (last-index-found - first-index-found)
to paraphrase peter parker: with complex code comes great confusion 😉
:cheers:
08-03-2017 10:47 AM - edited 08-03-2017 06:35 PM
Sometimes a solution to searching a 2D array can be found by doing a forum search. 😄 No need to re-invent fire.
Going back 9 years, you could have found the following two VIs (Yes, today we would use a conditional tunnel as discussed above)...
... and the one doing a 1D search on the flattened 2d array found in the immediately following post.
08-03-2017 11:16 AM - edited 08-03-2017 11:16 AM
It didn't come up when I was searching. Thanks for the addition to this post