This widget could not be displayed.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

build 1D array using for loop

Hi guys,

 

I am testing out array. How do I create a 1D array of x-y using for loop?

0 Kudos
Message 1 of 8
(4,078 Views)

Hi Nextal,

 

another basic array question. Did you go through the basics courses offered by NI?

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 8
(4,074 Views)

Hi GerW,

 

I think I am not clear about my question, I mean I want to build a array containing only the difference(adding on to my code). No I did not go through, I am doing self research and writing simple program to test out.

0 Kudos
Message 3 of 8
(4,069 Views)

Instead of the bigger while loop replace that with a simple for loop and take the x-y outside the for-loop you will get an array of differences.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 4 of 8
(4,063 Views)

Hi Nextal,

 

then again:

- go through the basics courses!

- you already use a for loop to generate a 1D array, so why don't you use the same approach to generate the next array?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 8
(4,062 Views)

I understood the question as the difference between the following elements. So my solution would look like this:

 

 

Greets, Dave

Greets, Dave
0 Kudos
Message 6 of 8
(4,026 Views)

1d-array.png

0 Kudos
Message 7 of 8
(4,014 Views)

Nextal wrote:

I am testing out array. How do I create a 1D array of x-y using for loop?



OK, first of all you did not say what the array should contain. If you want an array that has one array element for each iteration of the while loop, you need to first think a bit harder. Your outer loop has no wait, thus it will spin millions of times per second and you will run out of memory soon, no matter how much memory you have. How many times should the while loop iterate? If you know the number before the program starts, you would use a FOR loop and autoindex at the loop boundary.

If you want to use a whiile loop, you need a mechanism to keep the array size reasonable. For small final arrays, you can just build the array in a shift register if you need it updated as it happens. If you only need the array after the loop stops, you can autoindex at the right loop boundary.

 

In any case, you should take a step back and decide what you really want. Currently the specifications are very vague and unreasonable.

0 Kudos
Message 8 of 8
(4,009 Views)