LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

array pattern

Solved!
Go to solution

Dear all,

 

I have tried to manipulate some array but am not successful.

 

Right now, i have a ref array : 1 2 3 4 5 6 7 8 9 10

       and a measured array  : 4.2 , 5.2 ,8.2, 9.2.

 

The measured array will be compared with the ref array and if the measured array falls within the range ref array, the value in the measured array will be recorded else it will be filled with zeros.

 

Finally the answer should be something like: 0, 0, 0, 4.2, 5.2, 0, 0, 8.2, 9.2, 0.

 

 

I have managed to get to the 1st iteration and return the result as : 0 ,0 ,0, 4.2, 0, 0, 0, 0, 0, 0 but unable to proceed further.

 

What must i do to get the desried results? I have attached a sample VI.

 

Can anyone help me on this? One thing is that both measured and ref array will always be in ascending order, how do i code them to run more efficiently?

 

Thank you!

 

 

0 Kudos
Message 1 of 7
(3,288 Views)

Dear all,

 

I have managed to get the answer after some coding. May i know is there a better way to code it more efficiently? Attached is the code.

 

The data that i am dealing with is a few thousand values and i am wondering if this code is efficient. How to make it more effiicient?

 

Thank you!

0 Kudos
Message 2 of 7
(3,274 Views)

Is the ref array a plain [1,2,3..N] array. In this case you would not even need it, right?

 

Try this...

 

Also:

What should happen if there are multiple values for the same bin?

You probably need to size the output array for wider data.

0 Kudos
Message 3 of 7
(3,269 Views)

HI Joven,

check the attached VI snippet.

 

Regards,

GK

0 Kudos
Message 4 of 7
(3,263 Views)

Nope it is not plain number 1,2 .... It is some number with decimal places.

 

Any changes need to make in the VI?

 

 

 

 

0 Kudos
Message 5 of 7
(3,255 Views)
Solution
Accepted by topic author Joven

@Joven wrote:

Nope it is not plain number 1,2 .... It is some number with decimal places.


So why is it I32 then???

 

What is the significance of your +/-0.3. You really need to define the problem better. If the ref array is not integer, then make an example with more typical data.

 

Here's a quick draft using the reference array. Probably needs some tweaks, but should get you started.

 

0 Kudos
Message 6 of 7
(3,247 Views)

Dear Alten,

 

Yah thanks for the help. The range is necessary to find the measured value that falls between the ref range of +/-3. I manage to make some changes and tweaks and come out with the desired result. It is much shorter using replace array subset function. Thank you for your and everyone help!

0 Kudos
Message 7 of 7
(3,235 Views)