05-17-2013 08:25 PM
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?
Solved! Go to Solution.
05-17-2013 09:05 PM
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).
05-17-2013 09:23 PM
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?
05-17-2013 09:25 PM - edited 05-17-2013 09:26 PM
Right-click the array-to-cluster primitive and change the setting "Cluster Size..."
05-17-2013 09:39 PM
thank you!!
05-18-2013 12:29 AM
@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!
05-18-2013 12:15 PM
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!
05-18-2013 12:26 PM
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
05-18-2013 02:25 PM - edited 05-18-2013 02:28 PM
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).
05-18-2013 03:29 PM
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!