07-04-2015 11:58 PM
Hello. I am using Labview 2014 and need your help.
Please see the attached image which program is for appending segmented 1D-arrays to 1D array.
My purpose is to initially choose (or set) the number of controller (or No. of segmentation) so that I don’t need to change the program code to match the desired number of segmentation. For example, the No. of segmentation in the program as shown below is four and should be modified if I need to segment more or less than four.
I have two questions,
Thanks,
Converser
Solved! Go to Solution.
07-05-2015 01:39 AM - edited 07-05-2015 01:48 AM
Hi,
See my relply bleow questionwise
I aasume you got your intended 1D array.
Here you can use the shift register and the logic to change segmentation value automatically, use While or FOR loop.
2. Do you know the easier way to append segmented 1D-arrays to 1D array? I think my code have many duplication.
yes, you do not need to use these many duplication, use the shift register(same as above answer) and build array in concate mode (which you are using in your code)
Refer following picture
07-05-2015 10:49 AM
I'm going to assume you have a 2D array of data ("Data"), with columns representing Channels and rows representing Samples, and what you want to do is to "pluck out" a subset defined by an array of clusters having "Channel", "Start Row", and "# Rows" that you've determined somewhere else. Note that this allows you to select samples from multiple Channels (for example, two samples from Channel 1, then 4 samples from Channel 3), but does not (directly) allow you to select "Sample #5 from Channels 1-3" (though you could "fake it" by selecting Channel 1, Sample 5, 1 sample, Channel 2, Sample 5, 1 sample, Channel 3, Sample 5, 1 sample).
The first For loop illustrates filling the Selection array in a manner similar to your example, choosing the first two of every 5 entries in Column 4 (I coded it as "4 decremented" to emphasize Column 4). Notice that I've made the Cluster Definition a TypeDef with Channel, Sample, and # Samples -- it is a good idea to name/define all of your Clusters.
The second loop does all of the Selection for you, based on the Selection Array you generated in the first loop. First, you select the Channel you want, then extract the samples. I used the Concatenation Output Tunnel available since LabVIEW 2013, obviating the need for a Shift Register to "build up" the array.
Bob Schor
07-07-2015 03:50 AM
Thanks Amit and Bob.
But I have two remaining questions.
(1) I made a mistake in my example expression. It is right that my purpose is to "pluck out" the subset however the each "Start Row" may not be defined by the logic because it is determined from experimental observation. Therefore, the interval between subset is arbitrary. For example, Bob, in his example, the interval is set to 5 but the value is irregular. Do you still have solution?
(2) Due to my little knowledge, I have difficulty understanding Bob's code. I tried to follow your code but even this is not straightforward for me. As shown in the picture below, I cannot connect between Bundle and Bnbundle. I don't know much about the bundle and TypeDef. Also, why didn't you define the iteration number in second For-loop? Would you please explain your code more easily?
Thanks,
Converser
07-07-2015 04:02 AM - edited 07-07-2015 04:03 AM
Hi converser,
As shown in the picture below, I cannot connect between Bundle and Bnbundle. I don't know much about the bundle and TypeDef.
Well, the LabVIEW help explains the cluster functions and typedefs…
And Bob used (Un)BundleByName and a typedef'ed cluster with three numeric controls.
Also, why didn't you define the iteration number in second For-loop?
Ever heard of "autoindexing"? It's a very important feature in LabVIEW!
For example, Bob, in his example, the interval is set to 5 but the value is irregular. Do you still have solution?
Use an array input to the first FOR loop…