LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to truncate the elements from an 1-D array from and upto a certain value

Solved!
Go to solution

hello,

i have got data in the form of 1-D array but now i want to truncate it from and uptoa certain value say i want the elements from 0 to 2 (elements are also in negative and greater than 2) .

how should i start this or how to do it,i want this data for further analysis.please do respond as i have to submit my project this weekend

0 Kudos
Message 1 of 9
(2,604 Views)

Wire the array to a For Loop and use a "In range and coerce" function where the "In Range" output gets wired to the condition terminal of an indexing tunnel coming out of the For Loop.

 

 


@jyot445

...how should i start this or how to do it,i want this data for further analysis.please do respond as i have to submit my project this weekend


Since this sounds like a homework problem I will let you learn about LabVIEW by trying to figure out what I just wrote.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 9
(2,601 Views)

"truncate" implies removing a consecutive range of elements from either end base on index. If I read this right, you want to "filter" based on value (not index).

If you are not clear about terminology, please provide a more explicit example. For example what kind of result would you expect from the following array: [1,2,5,1,9,4,1]?

0 Kudos
Message 3 of 9
(2,579 Views)

yes,this is what i want to do;filtering.from the array as you have given i want data to be shown above 1 and below 8

0 Kudos
Message 4 of 9
(2,577 Views)

@jyot445 wrote:

yes,this is what i want to do;filtering.from the array as you have given i want data to be shown above 1 and below 8


We have no idea which post you are replying to and even then, we have no idea what "this" means. Are you talking about "value" or "index" when you say "above 1 and below 8"

0 Kudos
Message 5 of 9
(2,568 Views)

@jyot445 wrote:

yes,this is what i want to do;filtering.from the array as you have given i want data to be shown above 1 and below 8


Then add a Boolean Not to the output if the "In Range" I mentioned in the solution I posted above.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 9
(2,566 Views)

@altenbanch

When I acquire my data I get a 1-D array with anywhere from 10 - 30 data points. There are always some good data points & the rest are of no further use . A good data point is in the range of 0-3(it can be any specified value) & a bad point is below 0 and above 3(numeric value).how can I filter out these bad points? I am with labVIEW 2016 version.

 
 
0 Kudos
Message 7 of 9
(2,528 Views)
Solution
Accepted by jyot445

Hi iyot,

 

do as has been suggested several times:

- use InRangeAnCoerce to determine "good" or "bad" samples (are there also ugly ones? :D)

- put a FOR loop around your IR&C function to autoindex all samples from your array

- use a conditional output tunnel to only output the "good" samples…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 9
(2,521 Views)

@jyot445 wrote:

@altenbanch

When I acquire my data I get a 1-D array with anywhere from 10 - 30 data points. There are always some good data points & the rest are of no further use . A good data point is in the range of 0-3(it can be any specified value) & a bad point is below 0 and above 3(numeric value).how can I filter out these bad points? I am with labVIEW 2016 version.

Yes, we got that by now and you have received exact advice from Ben and Gerd that you seem to ignore(?). Is your LabVIEW version so old that you don't have the conditional tunnel? In that case the solution is very slightly more complicated, but you should be able to figure it out.

 

Here's what Ben meant long (long!) ago. Note that if the further analysis assumes equal time spacing of the points, this will no longer be true after filtering. (don't do a FFT or graph on a chart!) Also note that the limits can be inclusive or exclusive (look at the diamonds on the icon). Of course even if a value is in the correct range, it could still be bad for some other reason and there is no way to tell.

 

FIlterArray.png

(Also note that the primitive can be inside or outside the loop, something you might consider testing if the arrays are gigantic. While the primitive could possibly be faster when operating on an array, the additional cost is allocating a boolean array. Only a careful benchmark can tell what's best but it probably really does not matter. OTOH, the compiler might move things around anyway. ;))

 

 

0 Kudos
Message 9 of 9
(2,500 Views)