LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

index of all zero values in 1D array

Solved!
Go to solution

sylvainDCU wrote:
It precisly my problem, because I'm working with floating poin numbers... I think, i need to use "Threshold 1D Array". What do you think ?

That's not what Threshold 1D Array is meant for. Please read the Help on that function. That function will tell you the fractional index where you can find a value in an array. This is based on finding consecutive elements such that the value you're seeking is more than the first and less than the second. It also requires the array to be sorted in ascending order. This defeats the purpose of what you're trying to do.

 

The In Range and Coerce will tell you if something is approximately zero based on what your definition of "approximate" is. One way this can be done is this way:

Approximately Zero_BD.png

Message Edited by smercurio_fc on 07-28-2009 12:33 PM
0 Kudos
Message 11 of 19
(3,857 Views)

sylvainDCU wrote:
I would like to index all zero values in a 1D array. the problem is my points fluctuate around zero without reaching the zero value. So I need to do interpolation between the points.
I don't know how I can index all zero value. Can you please help me ?
regards,
Sylvain

 

Hi Sylvain,

 

It's unclear to me if you need the index of the elements around zero (a postive number followed by a negetive number, or vise versa) or an interpolated value between those two indexes?

The index of an array is just a number, does that number mean something, time, succesive measurements, .... .... If not, I think it's meaningless to interpolate the index.

 

The attached VI returns the first index of two consecutive numbers with different sign, zero crossing.

If you want to know the locations of zero crossings you can use it, as is.

If you want to interpolate those consecutive numbers, add the interpolation VI in the "False" case.

 

Unclear? Ask 🙂

 

0 Kudos
Message 12 of 19
(3,854 Views)

this is my 1D array.

I would like to know the indices of my array where the profile is equal to zero.

 

Sylvain

 

Download All
0 Kudos
Message 13 of 19
(3,852 Views)

Your problem is noisy data, else you could do something like discussed here. Due to the noise, it could flip the sign a few times in a row.

 

You probably should find the approximate place of each zero crossing and then do e.g. a second order polynomial fit of all "near" data at each location.

0 Kudos
Message 14 of 19
(3,831 Views)

Ha Ha!

 

No zero crossing in your data. I subtracted off the mean and looked for sign changes. AS Christian mentioned noise is an issue. Run your data thru a filter first to avoid the multiple crossing at or near zero.

 

Zero_Crossing.PNG

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 15 of 19
(3,817 Views)

Hello,

 

For a bit of fun, I added a software filter:

 

filteredWave.PNG

 

I modified Ben's VI for this, its attached.

 

 

0 Kudos
Message 16 of 19
(3,781 Views)

Hello,

 

You may also find this a useful resource.

Message Edited by macaba on 07-29-2009 04:25 AM
0 Kudos
Message 17 of 19
(3,778 Views)

macaba wrote:

Hello,

 

For a bit of fun, I added a software filter:

 

filteredWave.PNG

 

I modified Ben's VI for this, its attached.

 

 


 

Re: Software filter

 

If the exact timing of the zero crossing is important then a "zero-phase-shift filter" should be used. Other filter can introduce a phase shift that will throw off the timing.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 18 of 19
(3,754 Views)
Solution
Accepted by topic author sylvainDCU

A very good point that escaped my mind earlier, FIR has linear phase characteristics, so that should be the digital filter of choice.

 

Thanks for pointing that out Ben!

0 Kudos
Message 19 of 19
(3,749 Views)