DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Find exact index of local maximum PNo() and ChnFind() seem problematic

Solved!
Go to solution

Good day all DIAdem experts!

 

I'm after some help and am wondering if what I'm intending on doing is possible, as far as DIAdem's fucntions are concerned.

 

I have some cyclic data (aquired as one continous dataset), which I am able to indentify individual events. Within each of these events, I am using the StatBlockCalc, so calculate an effective local maxima and minima (within a specified index range). I wish to then use the computed maximum, of a specific channel, to then 'read off' an effective maximum across the other channels.

 

I have tried using both the ChnFind and PNo functions and both give results that often fall outside of the upper and lower index bounds of that event. I believe this is attributed to the fact that these functions search for a value closest to the value in question, and NOT for that exact value (rounding errors may also be playing a part). Please note this is not a criticism of the functions, as I believe what I am asking for may be more computationally intensive (as opposed to hunting for the nearest value).

 

So my question, is this feasible? To calculate a local maximum and then use this value's index to read across the remaining channels (to determine values at that maximum).

 

Hopefully what I am asking for is clear, if not then please feel free to ask away.

 

Kind regards

 

Dan

0 Kudos
Message 1 of 6
(5,087 Views)

Hi Dan!

 

I understand your problem, but I am curious as to how you separated the individual events. The ChnFind and PNo functions search from the beginning of the channel, so if you haven't separated the events, they will just give you the index of the first instance of the specified value. I can't think of any function that can solve this issue for you, but you could use the PNo function to find the row, check that it is within a specified range, then split the events into separate channels and search those channels to find the other index values. 

 

It may be useful to send over some screencaps of your script and data so I can understand you more clearly. 

 

Cody

0 Kudos
Message 2 of 6
(5,004 Views)

Hi Dan,

 

The ChnFind() and ChnFindReverse() functions have an optional parameter to specify the starting point of the search.  The PNo() function always searches the whole channel, no matter what.  If you have access to DIAdem 2015, I would highly recommend the new ChnEvent...() commands, which should give you much better tools to address your situation.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 3 of 6
(4,982 Views)

Hi Cody

 

Thank you for your response. My events have been isolated by a rising-falling edge algorithm which has been adapted based on code found on these very forums. This then gives me my effect index limits, into which form the index range that the statblockcalc() function determines the maximum between.

 

I believe I have manage to figure out a 'work-around' which gives me more reliable results. After performing a more indepth investigation into my initial theory, into why I think the logic was failing, I was able to apply a correction method.

 

What I believe was/is happening is that the the PNO() function finds an index which corresponds to a maximum that is close (if not exact) to the computed local maxima - this I firmly believe is caused due to a rounding error.

 

So, onto my 'work-around'. I am now computing the local maxima, finding 99.9% of that value (ie. max*0.999) then using the ChnFind("[1]/[1]=>"&(max*0.999),IdxStart). So essentially I reduce the local maximum by 0.1% and find the first value that exceeds the reduced value - which for all intents and purposes gives me the correct index.

 

Bit of a mess, but seems to work well - any thoughts?

 

Kind regards

 

Dan

0 Kudos
Message 4 of 6
(4,980 Views)
Solution
Accepted by danz001

Hi Dan,

 

If you want to attack this from the rounding error side, then I suggest inserting the ValEqual() function into your search expression-- it was designed to avoid the rounding issues you sound like you're running into.  My other recommendataion would be to abandon PNo() and use instead ChnFind() with the known starting index from your index window.  This will run faster and find the right extremum.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

Message 5 of 6
(4,964 Views)

Hi Brad

 

Thank you for your input, the ValEqual() function provides a sufficient logic in conjuction with the ChnFind() to allow for the correct detection of the appropriate index. You are the man!

 

Kind regards

 

Dan

0 Kudos
Message 6 of 6
(4,925 Views)