LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Repeat elements of an array

Lets say I have an array like this.                                 

 

                               
1 0 0 0 1 1 0 0 0 0 0 0 0 1 1 0
                               
0 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0
                               

 

 

 

Now I want to change this array and copy each row n time. Let's say for now n=1    so the array should  become like this. 

 

1 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0
1 0 0 0 1 1 0 0 0 0 0 0 0 1 1 0
0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0
0 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0
                               

 

 

and if n=2 then the below table 

 

1 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0  
1 0 0 0 1 1 0 0 0 0 0 0 0 1 1 0  
1 0 0 0 1 1 0 0 0 0 0 0 0 1 1 0  
0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0  
0 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0  
0 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0

 

 

 

 

so i should add the new copied rows and shift the table down. And as can be seen the one before last bit should always follow this pattern 1,01,011 then 0111

 

Could you please help me to implement it in LabVIEW

 

Thanks

 

 

 

 

 

0 Kudos
Message 1 of 4
(3,126 Views)

Hi tintin,

 

you might start like this:

check.png

I used U16 datatype to represent your 16 bits per row.

The bit setting can be made in dependance of the loop iterator "i" of the inner loop: IF i=0 THEN clear bit ELSE set bit...

Best regards,
GerdW


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

Thank Gred

the probelm is if I change the bit in the inner loop then it will change for all n copies. While I would like to follow this pattern    : 1   01  0111   01111

0 Kudos
Message 3 of 4
(3,107 Views)

@tintin_99 wrote:

Thank Gred

the probelm is if I change the bit in the inner loop then it will change for all n copies. While I would like to follow this pattern    : 1   01  0111   01111


This is only true when applying the same bit modification in each iteration.   You can setup an array of values that contains the modifications that need to be done in each iteration and index this in the inner For Loop. If I correctly understood your demand, an OR operation should be the one that needs to be added to the inner loop.

0 Kudos
Message 4 of 4
(3,092 Views)