LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

increment values in array by comparing with an another array

Solved!
Go to solution

Hello there,

 

I've got an Array1 which contains values indexes more especfically. This array size can be variable from 1 to 20 elements.Then I want to create an Array2,  which will increment the value of all the elements by one each iteration except those elements or indexes stored in Array1.

 

I have tried almost everithing to do it, but I just cannot get my head around this. Any help?

 

THanks in advance

0 Kudos
Message 1 of 39
(5,171 Views)

Can you give some example datas for array 1 and 2 with small explanation

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 2 of 39
(5,159 Views)

Sorry..yes of course.

 

I forgot to mention the arrays are 1D.

As I said the Array1 woudl contain values ie.(2,3,4) that correspond to the indexes that I do not want to increment in Array 2.

 

So in the first iteration:

Array1=(2,3,4)

Array 2= (1,1,0,0,0,1,1,1,1,1,1)

 

In the second iteration let is say Array1 changes and is (1,2,3,4)

So Array 2 would be: (2,1,0,0,0,2,2,2,2,2,2)

 

In the third iteration Array 1 changes again and it is (0,1,5)

 

Array 2=(2,1,1,1,1,2,3,3,3,3,3)

 

and so on..

 

Thanks

 

0 Kudos
Message 3 of 39
(5,152 Views)

Hi Rcano,

 

what have you tried so far?

 

Try this:

check.png

Increment array2, but keep the values not to be incremented…

Best regards,
GerdW


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

why in each iteration array1 is changing? and you said you need to create array2

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 5 of 39
(5,142 Views)

Hi GerdW,

 

I have tried different ways, right now I have a mess of Vi, trying different approaches, will post one as soon as I get a decent result. I will look into your VI thanks a lot.

 

Hi Ranjeet_Singh

 

My array1 is storing the value of the(index) a [previous operation.FYI this operation is just the comparison of two arrays. Each element that mismatches the other element is stored in int. Please see link below, it is similar.

http://forums.ni.com/t5/LabVIEW/Compare-elements-in-an-array/td-p/162750

 

 

Anyway that is why I am talking about iterations, array 1 will change every iteration and Array 2 needs to register by incrementing the elements not shown in Array in one unit, every cycle or iteration.

 

Hope this helps to understand a little bit more my goal

 

Thanks to both of you

 

0 Kudos
Message 6 of 39
(5,128 Views)

Or I was thinking to step back, it probably easier:

 

What if I have two arrays 1D 10 elements each:

 

1st iteration)

 

Array1data(1,30,40,52,52,52,0,0,0,0)

 

Array2Comp(52,52,52,52,52,52,52,52,52,52)

 

 

I want an Array3 registering the matches between the elements of both Array1data and Array2Comp by incrementing 1 each iteration;

 

Array3result(0,0,0,1,1,1,0,0,0,0)

 

2nd iteration)

 

Array1data(0,0,0,52,52,52,52,52,0,0)

 

Array2Comp(52,52,52,52,52,52,52,52,52,52)

 

 

Now the Array3 will update the oveall count with the new matches ;

 

Array3result(0,0,0,2,2,2,1,1,0,0)

 

and so on..

 

Does it make it easier??

 

THanks

0 Kudos
Message 7 of 39
(5,100 Views)

Hi Rcano,

 

compare your input arrays and add the "equal" comparison result:

check.png

Best regards,
GerdW


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

Hi Gerdw

 

thanks for your reply.

 

I am not able to do what I want with your example. Please see attached my attempt. I do not find a way to store the final count incremented 1 by 1 as per every iteration.

The way to handle arrays in Labview, even the simplest operations really do not get into my brain these days

 

Any advise?

 

Thanks a lot

0 Kudos
Message 9 of 39
(5,077 Views)

Hi Rcano,

 

please convert your VI to LV2011 if you want me to help…

Best regards,
GerdW


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