08-30-2010 11:55 PM
Hello,
I've this 1D large array(~20000 entries), and I'm trying to build a small array of 20 samples each time and find it's min and max values.
Such that the small array goes from i to i+19 entries of the large array.
So far, I think I've managed to build the small array everytime, but the min and max values don't change with every "new" small array, I don't know what the problem might be.
It's on the lower part of the atteached vi, the upper part of the vi does Xsub(i+1)-Xsub(i) and works fine.
Any suggestion?
Thank you,
Solved! Go to Solution.
08-31-2010 01:54 AM - edited 08-31-2010 02:00 AM
Hi simply_me,
there are several faults in your VI:
- you cannot insert into an empty array on a arbitrary index (your shift register is initialized with an empty array. Just showing element #20 of an empty array doesn't fill it magically with elements...)
- Why don't you use ArraySubset to get 20 consecutive elements from your big array?
- Why do you initialize counter shift register with DBL values instead of using I32 numbers?
- Why do you convert numbers/arrays to dynamic datatype? That is complete nonsense...
I would start with something like this:
Edited: Now I included two ways to calc z(i+1)-z(i). No need for a formula node like in your other thread...
08-31-2010 02:06 AM
wow...you made it so simple, I've struggled with it most of the day.
I'll give it a try now.
Thank you,
08-31-2010 03:24 AM
Hi Gerd,
I think that the small array is still causing some problems, since the counter I put on it yields ~180 count (Max-Min>=10), and the differential counter (Xsub(i+1)-Xsub(i)>=10 ) yields only a count of 9.
Could it be because the small array is built like:
Let X be the small array of size 20
X[0-20]
X[1-21]
....
X[i-(i+20)]?
Or maybe I just don't understand the algorithm....
08-31-2010 03:30 AM
Hi simply_me,
your "differential counter" only compares consecutive array elements. So there are only 9 elements with a difference of >=10.
The "subset counter" compares the min/max of 20 consecutive elements. There are far more possibilities of having a difference of >=10, so you get a count of 180...
Without knowing your data the result seems ok for me
08-31-2010 03:35 AM - edited 08-31-2010 03:37 AM
Thank you for the quick reply.
Nine is the correct count, and I'm sure that 180 is correct too under different conditions.
My question was different though (or at least what I meant to ask).
Was I correct in my assumption for the "subset counter" algorithm?
Initially, I planned to have something like
X[0-19]
X[20-40]
.....
08-31-2010 03:44 AM
08-31-2010 04:02 AM - edited 08-31-2010 04:05 AM
Hi Gerd,
I've tried that but now it gives 8 instead of 9, at some point I'm sure both have to agree.
Sorry for nagging you, and thank you.... 🙂
08-31-2010 04:07 AM
08-31-2010 04:09 AM
Never mind, I've changed everything to 15 and it's working....odd.
Thank you very much for your help.