LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2d array to cluster

Solved!
Go to solution

Is there anyway to convert a 2 dimensional array to a cluster? im making a parking lot (which has columns and rows of parking spaces) and i want to convert it into a cluster inorder to unbundle the elements to use them for some other stuff, how can i do this?

0 Kudos
Message 1 of 15
(18,207 Views)
Solution
Accepted by pauEs1

A cluster is an assortment of elements,  so it doesn't have any meaning with respect to a 2-D array.

 

If you have a 2-D array, you will need to index each of the elements and assign them to the cluster.

 

One other possibility is to reshape the 2-D array into a 1-D array, then use array to cluster (with the # of elements set correctly in the right click menu of the function).

0 Kudos
Message 2 of 15
(18,202 Views)

I reshaped it into a 1D array but now when i use the array to cluster function i'm only getting an output of 9 elements of the array, not the 15 of them.  How can i get all of them into the cluster?

0 Kudos
Message 3 of 15
(18,199 Views)

Right-click the array-to-cluster primitive and change the setting "Cluster Size..."

0 Kudos
Message 4 of 15
(18,196 Views)

thank you!!

0 Kudos
Message 5 of 15
(18,186 Views)

@pauEs1 wrote:

Is there anyway to convert a 2 dimensional array to a cluster? im making a parking lot (which has columns and rows of parking spaces) and i want to convert it into a cluster inorder to unbundle the elements to use them for some other stuff, how can i do this?



It seem silly to create a cluster from a 2D array just to unbundle the elements later. You migh as well eliminate the middleman and simply index the 2D array elements to use them directly for "some other stuff" (your words). :D.

 

Can you elaborate on your thought process? Thanks!

0 Kudos
Message 6 of 15
(18,177 Views)

yeah hahaha I did end up eliminating the cluster, this is how it ended up, but the program isn't working the way it should.  Its basically a "smart park" system that notifies the people entering the parking lot, how many cars are parked on each floor, how many vacant spaces there are etc... but its not working and im going crazy!

0 Kudos
Message 7 of 15
(18,150 Views)

i actually think im going about all of this the wrong way but im just so stuck on the original way i did it that i don't know what to do from here to make it work.  I don't know if the shift registers were even the correct thing to put

0 Kudos
Message 8 of 15
(18,146 Views)

Well, for some reason you are using 1D arrays instead of 2D arrays.

 

Anyway, you code is way too complicated and a solution could probably fit on a postage stamp. To count the number of TRUEs in a boolean array of any dimension, you would simly use "boolean to (0,1)" on the array directly followed by "add array elements". No loops needed. Try it!

 

Some other comments. The number of iterations of your FOR loop is determined by the array size of the autoindexing array. Stopping the VI is probably not the right way to terminate it, it will terminate everything, including the while loop. The while loop spins millions of times per seconds recalculating the same thing over and over. It probably need a small wait (e.g. 100ms).

0 Kudos
Message 9 of 15
(18,135 Views)

i'm using 1D arrays because the array to cluster function doesn't work if i use 2D arrays, i changed the while loop i had in the VI i posted to a for loop, but im confused on how its going to work with this program (im really new at labview), i just want the numeric indicator i have (the display screen of the parking lot) to display the number of vacant parking spaces by counting how many the switches are turned off (when they're off, that parking space is vacant).  Do you recommend i keep the for loop or use a while loop? any other suggestions?

 

-Thank you!

0 Kudos
Message 10 of 15
(18,122 Views)