Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Divide by Zero - If/Try Loop

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-26-2018
08:34 AM

07-26-2018
08:34 AM

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.

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-26-2018
08:50 AM

07-26-2018
08:50 AM

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.

5 REPLIES 5

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-26-2018
08:50 AM

07-26-2018
08:50 AM

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.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-26-2018
08:58 AM

07-26-2018
08:58 AM

Re: Divide by Zero - If/Try Loop

Yes, I wrote it a bit strange..

Let me try one more time..

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-26-2018
09:04 AM

07-26-2018
09:04 AM

Re: Divide by Zero - If/Try Loop

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-26-2018
09:06 AM

07-26-2018
09:06 AM

Re: Divide by Zero - If/Try Loop

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.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-26-2018
09:14 AM

07-26-2018
09:14 AM

Re: Divide by Zero - If/Try Loop

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.