Skip to main content
1-Visitor
February 16, 2012
Question

Division by Zero

  • February 16, 2012
  • 1 reply
  • 2542 views

Hello,

I am stuck at one place and it gives me an error that divide by zero.

Facewidth has relation with pitch so in program it gives correct answer. But for after that range it gives zero value.

and because of the zero value it does not calculate SS which is surface stress.

In-short as the facewidth I need answers for SS, SB, SB1, and BHNW.

I am attaching the program. Please check it out. you will get more idea.

Thank you.

Jaydeep

1 reply

12-Amethyst
February 16, 2012

FFacewidth has 0 values, and you are dividing by that,

I added a small program to sort out the 0 values.

1-Visitor
February 16, 2012

Hello Wayne,

If I go with your program it gives me wrong answers.

Actually I also worked on the same problem and made some changes.

If you wanted to refer your program with mine you can see the attachment.

12-Amethyst
February 16, 2012

JaydeepPanchal,

I didn't check for the correct answer, just gave you a way to prevent division by 0. I see you filled the 0's with 1's, which is fine, if that gets you want you want.

Also, you could also assign NaN instead of 0 in the program, which may be better since I assume when division by 0 occurs the problem is actually not defined. NaN points will not plot.

Looks like I needed to change the index on Pitch in the program.