help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

help - warning division by zero


From: Joe Tusek
Subject: help - warning division by zero
Date: Fri, 25 Oct 2019 05:58:55 +0000

Hi,


I have code that uses ifelse statements to prevent the possibility of a division by zero. It appears though that all the conditions of the ifelse are evaluated as part of the ifelse execution and this results in a warning about a division by zero, even if the code should prevent such a case.

 

This leaves a warning of division by zero in the Command Window when the “executed code” had not resulted in one.

 

The code snippet has been crafted to generate the behaviour

 

>> ifelse (1==1,0,1/0)

warning: division by zero

ans = 0

>> ifelse (1==0,0,1/0)

warning: division by zero

ans =  Inf

>> ifelse (1==0,0,1)

ans =  1

 

Should this warning be supressed (so that it does not appear in the Command Window) when there was no active code that resulted in a division by zero?

 

Regards,
Joe

 

Joe Tusek (BE MBA)
Technical Director
23 Warabrook Boulevard, Warabrook, NSW 2304
P +61 2 4961 9000  M +61 418 669 250

 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]