DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Finding the position of the minimum value in a channel

Very occasionally, the following line of code fails to return the row number of the minimum channel value and returns 0 instead:

 

L1=Find("Ch('WkSpace')=ChnValMin('WkSpace')")

 

The values in WkSpace are generated from the cursor position in the View window and I can make the code work if I move the cursor little bit. So, it seems that DIAdem is being tripped by rounding errors perhaps. Is there a more robust way of writing the line of code to find the minimum value row number without falling foul of rounding errors?

 

Thanks.

 

Simon.

 

 

0 Kudos
Message 1 of 6
(2,583 Views)

https://forums.ni.com/t5/DIAdem/NOVALUE-when-using-ChnPropValGet-ChnPropGet-and-property-value/td-p/...

This is one of many topics talking about how many times the min/max values of a channel are not calculated by default when loading a channel (for performance purposes).  I usually use cch() function on a channel before accessing those values

0 Kudos
Message 2 of 6
(2,568 Views)

Hi , thanks for the response.

 

I'm not sure this is what's happening in my case. I did have more explanatory information in my post before I deleted it all! One of the points I should have made is that the same line of code worked perfectly if I asked for the maximum value. It was only the minimum value that it couldn't find. Also, it was a recently calculated channel, rather than a recently loaded one, so the characteristics should have been calculated already. This is why I think it's more to do with rounding than characteristic values.

 

Nonetheless, it may be prudent to ensure the characteristic values are computed beforehand anyway.

 

Regards.

0 Kudos
Message 3 of 6
(2,549 Views)

Find() or ChnFind() would return "0" if they did not find the value.  If you suspect the reason to be weird rounding mismatching, I would suggest PNo() function.  It will get back the row with the closest value.

http://zone.ni.com/reference/en-XX/help/370858M-01/functions/functions/pno/

Message 4 of 6
(2,539 Views)

Thanks for the suggestion. I can't use PNo() I'm afraid as I don't know the value that's being searched for - only that it's the minimum.

 

Regards.

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

If you are sure that the minimum gets calculated but think that Find() returns zero because it can't find an exact match (rounding mismatch as you mentioned), you can still use PNo() with the minimum and get the correct row back.

0 Kudos
Message 6 of 6
(2,522 Views)