LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Populating Array of cluster of 1D Array

Solved!
Go to solution

Hi All,

 

I am running into an issue with a 1D array of cluster of array data structure. Sadly I cant upload working code as its written in actor framework and divided over multiple actors.

 

We came up with a data frame which is a (1D array of cluster), which has all the elements required for data acquisition and analysis.

Tmajeed367_0-1712746516631.png

I am trying to populate Y-Data and X-Data array only. Approach taken is given below:

Tmajeed367_1-1712747079470.png

 

Test counter will run from 0-4 and resets back to 0. This increments port number to +1 and the process repeat again until the port goes above 17, when the actor completes execution.

 

I am trying to populate All Data array for counters 0-4 which should go into index 0 for port 1, when port increments to index 1 which is port 2, I want index 1 of all data array to be populated.

 

When I use build array or insert into array functions, on each test counter increment data is added to the index, based on port number, so for port 1 which is 0 index, my all data array has five entries governed by the test counter. When port goes to +1 i get another 5 entries and so on.

 

Using replace array subset does not populate the array as I thought and it comes back empty. I believe I need to initialize the array first to use this function, which I cant seem to figure out as incoming data is an array. Has anyone run into a similar problem or can provide a useful insight? I have attached a VI which is performing a similar task. I will appreciate any help. Best Regards

0 Kudos
Message 1 of 5
(157 Views)

What do you expect if you index into an empty array?

 

You probably want to initialize an array with default values if the correct final size, then use the IPE to update elements based on port number. You cannot insert into a position that does not exist, unless  you are at the end of the existing array.

0 Kudos
Message 2 of 5
(132 Views)
Solution
Accepted by topic author Tmajeed367

See if this can give you some idea about data manipulation. Of course you need to incorporate it into your own code where the data is only added when needed.

 

altenbach_0-1712775841917.png

 

Message 3 of 5
(127 Views)

The attached malleable VI will let you place items in an array without initializing it.

It pads the array as needed with default values.

"If you weren't supposed to push it, it wouldn't be a button."
Message 4 of 5
(110 Views)

Thanks for replying. I have used a similar approach where I initialize array for the number of ports before replacing data based on index number.

 

It works for this approach as I already know before hand the amount data I am expecting.

 

Thanks again for all your help

0 Kudos
Message 5 of 5
(65 Views)