LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to define an array of fixed length

hello, i have a basic application in which i need to define an array of size 19; and add 19 elements to it. 

 

Once 19 elements have been written to the array, i want to start writing to the array from index 0.

 

It's like in C language, where-in you define array_size in init, and once the array is full, you overwrite the 1st element and so on.

i hope my question makes sense...

 

any help is appreciated.

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 1 of 8
(11,139 Views)

You can define an array of size 19 with Initialize Array.  For loops are good ways to index through an array -- learn about them.  If you want to simply replace a numbered element, replace Array Subset can work (the subset if an array of 1 element).  More experienced LabVIEW users might use the In Place Element Array Index/Replace Element, but you should start with the For Loop.  There are good tutorials out there ...

 

BS

 

0 Kudos
Message 2 of 8
(11,129 Views)

Rotate 1D Array might be a useful function for you as well.

0 Kudos
Message 3 of 8
(11,100 Views)

Hello LV_Enthu,

 

As Bob said, there is the two way of initialize array, you can follow any of the method which are displayed in image.

 

Initialize.PNG

Vinal Gandhi, CLA
0 Kudos
Message 4 of 8
(11,090 Views)

Hi Check out these VIs as per your discription. You can try your own method. 

PBP
Labview 6.1 - 2019
Download All
0 Kudos
Message 5 of 8
(11,054 Views)

Hi PBP,

 

the OP said to use LV8.0, so your LV2012 VIs aren't accessible…

 

It's like in C language, where-in you define array_size in init, and once the array is full, you overwrite the 1st element and so on.

Try this:

check.png

It defines an array with a certain size and fills it by overwriting the elements. Thanks to QR operation it starts over with 1st element once the array "is full"…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 8
(11,048 Views)

Ohh Sorry,

Please Find LV8.0 version.

PBP
Labview 6.1 - 2019
Download All
Message 7 of 8
(11,036 Views)

I hope this is in a useable version for you. Basically it covers a solution in which you write values at arbitrary intervals. I used an event structure to make my point, but it could of course be a state in a state machine or a while loop or something...

 

Like RavensFan suggested, it uses the rotate 1D array to rearrange your array. You take the last element and places it first, then replace it with a new value.

Best regards,

Jarle Ekanger, MSc, PhD, CLD
Flow Design Bureau AS

- "The resistance of wires in LabVIEW is not dependent on their length."
0 Kudos
Message 8 of 8
(11,034 Views)