cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Divide by Zero - If/Try Loop

AdoS
6-Contributor

Divide by Zero - If/Try Loop

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. 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Werner_E
24-Ruby V
(To:AdoS)

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

View solution in original post

5 REPLIES 5
Werner_E
24-Ruby V
(To:AdoS)

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

AdoS
6-Contributor
(To:Werner_E)

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.  

AdoS
6-Contributor
(To:AdoS)

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 

Werner_E
24-Ruby V
(To:AdoS)

I realized what your main question is and just edited my answer above.

Guess that there is no perfect satisfactory solution as long as we cannot check if a variable already exists.

Best option may be to rather check for the critical variables which may cause the solve to fail if thats possible in your original worksheet.

AdoS
6-Contributor
(To:Werner_E)

Thank you sir, brilliant as always

 

I can use this as a start point to update sheet, this divide by zero kills half of the sheet, but at least now I can find my way out. 

Top Tags