How can I prevent a domain error in pow?
Submitted by Joe on Fri, 11/13/2009 - 22:15
I have a problem with a negative number causing a domain error in power to a fractional exponent. I have 2 calculations, one uses the fractional exponent, the other does not. Basically, if K is less than 0.3 then use a simple calculation and only if k >= .3 do the fractional power. I think I have the formula implemented correctly by using a merge to select between the two calculations, but VisSim seems to execute both calculations all the time.
Can you please help me with a best way to address this?
Answers
-
Submitted by Anders89 on Fri, 11/13/2009 - 22:20.
Either put a limit block on the input to pow with a lower bound of 0 and upper bound of 1e300, or you can put all the fractional power calc blocks into a single compound block.
Then Ctrl+Rt click on the compound and select 'Enabled Execution'. A red ball connector will appear on the top left edge of the compound. The block will now only execute if the value on that connector is true. So then feed the boolean condition 'k>=.3' into that enable pin to prevent execution for the conditions that give a negative exponent. This can also speed up diagram execution if you spend a lot of time in the k < .3 domain.0