LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Build An Array From An Array

Solved!
Go to solution

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,

0 Kudos
Message 1 of 17
(3,248 Views)

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:

22773i5C94425FE0E6AA45

Edited: Now I included two ways to calc z(i+1)-z(i). No need for a formula node like in your other thread...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 17
(3,235 Views)

wow...you made it so simple, I've struggled with it most of the day.

I'll give it a try now.

Thank you,

0 Kudos
Message 3 of 17
(3,227 Views)

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....

 

0 Kudos
Message 4 of 17
(3,216 Views)

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 Smiley Wink

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 17
(3,208 Views)

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]

.....

 

 

 

0 Kudos
Message 6 of 17
(3,203 Views)

Hi simply_me,

 

so you simply have to change to loop count N to arraysize/20 amd multiply "i" with 20 before feeding to the ArraySubset function to get elements [0..19], [20..39],...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 17
(3,191 Views)

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.... 🙂

Download All
0 Kudos
Message 8 of 17
(3,184 Views)

Hi simply_me,

 

i get a count of 9 on your data file Smiley Wink

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 17
(3,176 Views)

Never mind, I've changed everything to 15 and it's working....odd.

Thank you very much for your help.

 

 

0 Kudos
Message 10 of 17
(3,173 Views)