LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

array division handling zero division (CVI)

Hallo,
if I use the function Div1D to divide one array by another I get zero division error (some elements of denominator array may be zero). Is there any function handling zero division?
Thanks in advance,
Michele
0 Kudos
Message 1 of 4
(3,269 Views)

Michele, I have never tried the Div1D function but in looking at it just now I see that it returns error -20060 whenever a member of the denominator array is zero.  So one simple way to avoid this is to check your denominator array prior to calling the Div1D function.  If any member is zero, you will want to avoid calling Div1D.  Or perhaps set that member to some other non-zero value & somehow notify the operator of the bad data that was detected.

Regards,

Andy

0 Kudos
Message 2 of 4
(3,261 Views)

Thanks Andy,

I was looking for a "compact" function as Div1D but it works fine as you suggested.

regards,

Michele

0 Kudos
Message 3 of 4
(3,242 Views)
If your data does not extend below 0.0 then you can use Clip() to coerce data points at 0.0 slightly above zero so that you avoid the divide by zero exception. 

Message Edited by mvr on 05-23-2006 07:29 AM

0 Kudos
Message 4 of 4
(3,233 Views)