LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

NaN remover and interpolator

Hi,
I have an 1D array of numbers but there are also NaN's in it, does
anyone knows how to remove them and fill em in with interpolated
numbers:

So i have for example this:

5.67
NaN
3.46
2.56
4.68
NaN
NaN
3.21
1.04


And i want it to be this:

5.67
4.56
3.45
2.56
4.68
4.19
3.70
3.21
1.04


It a linear interpolation, If there is one NaN space: first value +
third value / 2 fill in.
Where the two NaN's are i do the following: (4.68 - 3.21)/ 3 = 0.49 ->
4.68 - 0.49 = 4.19 (first filled up NaN value) then 4.19 - 0.49 = 3.70
(second filled up NaN value) but now in LabView?!

Anyone?!

Best regards Thijs
0 Kudos
Message 1 of 3
(2,986 Views)
Hi,
no problem,
you can use function "in range".
I'll send an example to you.
Mike

Thijs Boeree wrote:

> Hi,
> I have an 1D array of numbers but there are also NaN's in it, does
> anyone knows how to remove them and fill em in with interpolated
> numbers:
>
> So i have for example this:
>
> 5.67
> NaN
> 3.46
> 2.56
> 4.68
> NaN
> NaN
> 3.21
> 1.04
>
> And i want it to be this:
>
> 5.67
> 4.56
> 3.45
> 2.56
> 4.68
> 4.19
> 3.70
> 3.21
> 1.04
>
> It a linear interpolation, If there is one NaN space: first value +
> third value / 2 fill in.
> Where the two NaN's are i do the following: (4.68 - 3.21)/ 3 = 0.49 ->
> 4.68 - 0.49 = 4.19 (first filled up NaN value) then 4.19 - 0.49 = 3.70
> (second filled up NaN value) but now in LabView?!
>
> Anyone?!
>
> Best regards
Thijs
0 Kudos
Message 2 of 3
(2,986 Views)
Hi Thijs

You could test each number in the array with the "Not a
Number/Path/Refnum?" function in the comparison palette. Then, if you
find a NaN value, if you stored the previous value in a shift register,
keep that value. Check for any subsequent NaN's (and count how many)
until you find another non-NaN, and then do your maths to fill in the
appropriate array values (carry the array on another shift register).

Paul

Thijs Boeree wrote:

> Hi,
> I have an 1D array of numbers but there are also NaN's in it, does
> anyone knows how to remove them and fill em in with interpolated
> numbers:
>
> So i have for example this:
>
> 5.67
> NaN
> 3.46
> 2.56
> 4.68
> NaN
> NaN
> 3.21
> 1.04
>
> And i want it to be this:
>
> 5.67
> 4.56
> 3.45
> 2.56
> 4.68
> 4.19
> 3.70
>
3.21
> 1.04
>
> It a linear interpolation, If there is one NaN space: first value +
> third value / 2 fill in.
> Where the two NaN's are i do the following: (4.68 - 3.21)/ 3 = 0.49 ->
> 4.68 - 0.49 = 4.19 (first filled up NaN value) then 4.19 - 0.49 = 3.70
> (second filled up NaN value) but now in LabView?!
>
> Anyone?!
>
> Best regards Thijs

--

Research Assistant
School of Physiotherapy, Curtin University of Technology
Selby Street, Shenton Park, Western Australia, Australia. 6008
email: P.C.Davey@curtin.edu.au
Tel. +61 8 9266 4657 Fax. +61 8 9266 3699

"Everyone who calls on the name of the Lord will be saved." Romans 10:12
"For all have sinned and fall short of the glory of God, and are
justified freely by his grace through the redemption that came by Christ
Jesus." Romans 3:23-4
0 Kudos
Message 3 of 3
(2,986 Views)