11-28-2012 10:23 AM
Hello All,
I'm trying to rearrange my digital waveform by having a front panel control which allows the user to dynamically set the channel.
On the front panel, I have typedef consisting of a cluster of unsigned integers. I want to sort this cluster by the numbers, and be able to operate on cases by label.
I understand how to assemble digital waveforms with Digital Subset and Append Digital Signals, but I dont know how to sort the data structure that I have created.
I'm sure there is an easy way to do this and it is just escaping me. Am I on the right track with my data structure?
Solved! Go to Solution.
11-28-2012 10:50 AM
What exactly do you mean by "sort the cluster"? Do you have an array of these clusters that you want to sort based on a particular element of the cluster?
Please provide an example of the data before, and how you want it to look after the operation you are trying to do.
11-28-2012 11:21 AM
The cluster contains the labeled numerics as indicated in the attachment. What I want is a data structure of the labels, sorted by the numerics. It's a convoluted data structure, and probably isn't what the best way to go about it.
11-28-2012 11:27 AM - edited 11-28-2012 11:37 AM
You can use a Cluster to Array function to get an array of the cluster values.
You can create a 1-D array of strings where you hardcode in the labels. (There should be ways through scripting to programmatically get the labels, but I don't think that is worth the effort.)
If you bundle up your array of numbers with your array of strings so that you have an array of clusters (each array element is a cluster of the value and the string), you can then sort the 1-D array.
Even simpler. Scripting is not necessary to get the names of the elements. I added an example VI.
11-28-2012 11:28 AM
Thanks!