11-09-2012 06:06 AM
Hi everybody!
I have an array of cluster (each cluster contains 4 values) and depending on user interactions, new clusters are added to the array. I'd like to implement a "Clear" button which deletes all the elements inside the array but I can't find a solution so far. The best I can do is to set all the cluster elements to 0 but the cluster itself is still in the array.
Does anybody know how to do that?
Many thanks,
Julien
Solved! Go to Solution.
11-09-2012 06:12 AM
I would assume delete array subset will do it.
Something like this:
11-09-2012 06:12 AM - edited 11-09-2012 06:24 AM
Hi jfcors,
the cluster has to stay in the array as it defines the datatype of the array.
You also seem to mis-understand the term "empty array": an array is empty when there are no elements in it!
Snippet:
@aCe:
Your example only deletes one element in an array, but not the whole array! Sorry, it's correct...
11-09-2012 06:23 AM
@GerdW: It does delete everything. See array length wired to the length input.
11-09-2012 06:28 AM
Thanks a lot!
Indeed it wasn't clear. What I wanted is to remove all the elements of the array, except the first one so that the array type is still defined.
About your solution: you show two ways to do it right? What are the names of the subvis you use? I couldn't find them in the Array palette.
Cheers,
Julien
11-09-2012 06:33 AM
@jfcors wrote:
Thanks a lot!
Indeed it wasn't clear. What I wanted is to remove all the elements of the array, except the first one so that the array type is still defined.
The array type is also defined if the array is empty. No need to keep one element for that.
11-09-2012 06:34 AM - edited 11-09-2012 06:35 AM
Hi jfcors,
IndexArray, InitArray and ReshapeArray. All to be found on the Array functions palette...
And the picture is a snippet. You can download and put it in your block diagram.
There's a context help entry for snippets. Ever considered to read the help?
11-09-2012 06:44 AM
Thanks for your help, it works perfectly.
I read the help all the time, but sometimes it is easier to ask for help directly.
Bests,
Julien