07-28-2009 12:32 PM - edited 07-28-2009 12:33 PM
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:
07-28-2009 12:33 PM
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 🙂
07-28-2009 12:36 PM
this is my 1D array.
I would like to know the indices of my array where the profile is equal to zero.
Sylvain
07-28-2009 12:55 PM
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.
07-28-2009 01:20 PM
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.
Ben
07-29-2009 04:13 AM
Hello,
For a bit of fun, I added a software filter:
I modified Ben's VI for this, its attached.
07-29-2009 04:25 AM - edited 07-29-2009 04:25 AM
07-29-2009 07:10 AM
macaba wrote:Hello,
For a bit of fun, I added a software filter:
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
07-29-2009 07:14 AM
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!