LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

add dynamic elements into an array

Solved!
Go to solution
From a source I am getting set of 50 bits of data. i am getting this 5100 times. I need to dynamically add the data into a single 1d array.So my requirement is to have 255000 elements in an array and keep on adding the 50 elements one after the other in the corresponding index.
 
my ultimate aim is to convert this back to 2d array using reshape array and then map into an image. please help.
Message 1 of 10
(5,107 Views)

hi muks,

you can create an array using "initialize array" function. Set the number of elements to 255000 and use the replace function to write your values in this array. After that you can reshape the array to a 2D Array.

Mike

Message 2 of 10
(5,101 Views)
Hi!
   Depending on your needs, you can build an array of 50 booleans, or a cluster of 50 booleans, and insert it into a 5100-elements array of arrays.  Can you say more about your task, so that we can see if there's a more optimized way of storing data?

   From your post, it seems like you're trying to build a 255000-elements boolean array, is it so? You can directly build a 2D array.

   Just use the initialize array to build an empty array of 5100 elements and then use "replace array subset" function, or, starting from an empty array, you can use "build array" function.

   Which way do you prefer? Just start coding something, then we can take a look at it...


   Have a nice day!

graziano

Message 3 of 10
(5,100 Views)
Please find the attachment which contains the block diagram.In the "U8 array read 3" i am getting the 50 bit value but i need to store them sequentially in a array.
 
Hope this is clear. thanx a lot for your reply.
Message 4 of 10
(5,090 Views)
To explain more clearly, when i run the program The program reads the bits in the U8 array and we can see the changes.the program stops after reading 255000 times the 50 bit data.I need to add all the data into a single array for further processing.
Message 5 of 10
(5,087 Views)

Hi muks,

if you need a 1D array you can simple reshape your 2D array after the while loop.

Mike

Message 6 of 10
(5,081 Views)
Hi muks,

first: don't rename your BMP pics to JPG! Please convert them to JPG or even better PNG!

You already get a 2D array of your "bits" at the right side of the while loop. You just need to transform it to a representation you can process... And maybe use some more efficient array building as mentioned before: Initialize an array and replace elements of the array by the values delivered from your subvi!

And what format are your bits in? You get an U8-array from this subvi. Are these 50 U8 each representing one bit or are these 7 U8 containing those 50 bits mentioned?
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 10
(5,080 Views)
Please see the attachment
Message 8 of 10
(5,076 Views)
Solution
Accepted by topic author muks
Hi muks,
i try something for you. See the attachment please. I hope it helps you.
Mike
Message 9 of 10
(5,070 Views)

hey mikey,

                Thanx a lot .  but just imagine i need to handle 20,40000 bits of data.will let u know the time taken in a few minutes.Meanwhile thanx a lot

Message 10 of 10
(5,064 Views)