LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Aappending segmented 1D-arrays to 1D array

Solved!
Go to solution

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,

  1. Do you know how to automatically change the No. of segmentation if I initially set the segmentation number? For example, if the No. of segmentation is initially set to five, the only five ‘start’ and ‘length’ controllers are displayed.
  2. Do you know the easier way to append segmented 1D-arrays to 1D array? I think my code have many duplication.

Thanks,

 

Converser

20150705_135530.jpg

 

0 Kudos
Message 1 of 5
(4,129 Views)
Solution
Accepted by topic author converser

Hi,

 

See my relply bleow questionwise


 

  1. Do you know how to automatically change the No. of segmentation if I initially set the segmentation number? For example, if the No. of segmentation is initially set to five, the only five start and length controllers are displayed.

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 

Untitled.png

 

 

-
Amit
CLAD
0 Kudos
Message 2 of 5
(4,087 Views)
Solution
Accepted by topic author converser

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).

Selection.png

 

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

0 Kudos
Message 3 of 5
(3,942 Views)

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

 

20150707_172310.jpg

0 Kudos
Message 4 of 5
(3,783 Views)
Solution
Accepted by topic author converser

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 5
(3,772 Views)