Skip to main content
1-Visitor
July 26, 2018
Solved

Divide by Zero - If/Try Loop

  • July 26, 2018
  • 1 reply
  • 3505 views

Gents,

 

Hope all of you are good. I have one more question, and as always this kind of stuff get complex only when I do it. 

Under procedure I get some values in zero, which then needs to be divided. However in my case it would simply mean that this portion of the result shall not influence and it needs to get out of the equation (simply wave effect is not applicable after certain depth). 

 

Please note, this attached sheet is simplified to show what I need to do, original one is 15 pages so far. 

 

So I'm trying to make some kind of loop which shall state if there is no valid result from above step, return 1. 

 

Looked throe the manual and this forum, but can't find nothing, It looks like I runned into software limitation (due to fact that is not logical what I want to do)..

 

Thank you in advance. 

 

 

 

 

Best answer by Werner_E

I would not call it a software limitation.

 

You are asking for a solution of the equation 0*T=3

What answer did you expect for T?

 

Here is a way to check if the calculation got a result. Unfortunately to be able to use the try and catch you have to use a numeric method to solve the equation. I have chosen the root command in the version where you have to provide limits for the solution. This is the drawback of this method as it would mean that you have to know two values, one to the left and one to the right of the expected solution.

Another option would be to use a solve block which is turned into a function of some of the critical vatriables and call that function instead of root. Drawback is that its more elaborate, benefit is that you just have to provide one sensible guess value. Its a long standing wish to implement a way to be able to determine if a variable already exists.

B.jpg

1 reply

Werner_E25-Diamond IAnswer
25-Diamond I
July 26, 2018

I would not call it a software limitation.

 

You are asking for a solution of the equation 0*T=3

What answer did you expect for T?

 

Here is a way to check if the calculation got a result. Unfortunately to be able to use the try and catch you have to use a numeric method to solve the equation. I have chosen the root command in the version where you have to provide limits for the solution. This is the drawback of this method as it would mean that you have to know two values, one to the left and one to the right of the expected solution.

Another option would be to use a solve block which is turned into a function of some of the critical vatriables and call that function instead of root. Drawback is that its more elaborate, benefit is that you just have to provide one sensible guess value. Its a long standing wish to implement a way to be able to determine if a variable already exists.

B.jpg

AdoS1-VisitorAuthor
1-Visitor
July 26, 2018

Yes, I wrote it a bit strange.. 

Let me try one more time..

 

Capture1.JPG

 

if answer for T2 is not real number, return 1.  

AdoS1-VisitorAuthor
1-Visitor
July 26, 2018

Then I wrote again 0*T=something 🙂 there you understand my confusion, mathematically not possible I understand it, but I just thought a person can find way out if