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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

if ...else condition in Mathcad Prime 4

sshu
4-Participant

if ...else condition in Mathcad Prime 4

I tried to look up soil layer properties based on layer depth shown in the table using function Shaft_Matrix. Don't know why the Shaft_Matrix function returns layer 2 properties at depth 5'. I have been stuck with this for a while, still cannot figure it out. I would really appreciate if anybody can help. Thanks 

ACCEPTED SOLUTION

Accepted Solutions
LucMeekes
23-Emerald III
(To:sshu)

Maybe this helps to explain:

LM_20190325_Lookup.png

 

Success!
Luc

View solution in original post

8 REPLIES 8
LucMeekes
23-Emerald III
(To:sshu)

I'll gladly admit I'm blind, but I don't see a depth of 5' .

Can you pinpoint precisiely on the sheet where your problem lies?

 

Success!
Luc

sshu
4-Participant
(To:sshu)

Thanks Luc!

I have a table where each layer has a bottom depth and other properties, say layer 1: bottom depth of the layer is 5 ft, blow count is 20, then layer 2: bottom depth is 10 ft and blow count is 15..... Then I define a function (Shaft_Matrix) which  looks up soil properties at any depth of the drilled shaft.  The function is supposed to return soil properties of Layer 1, but actually it returns Layer 2 instead (See  Matrix Shaft_M, where at depth 5, third column should be 20 (Layer 1), but actually it is 15 (Layer 2)), and the all returns from depth 5' below move up by one ft, which leads to no soil properties assigned for bottom layer (Depth 50').

I deleted all other functions and tables irrelevant to this issue and attached here. Please help look into it.

Thanks a lot.

Shan 

LucMeekes
23-Emerald III
(To:sshu)

Maybe this helps to explain:

LM_20190325_Lookup.png

 

Success!
Luc

sshu
4-Participant
(To:LucMeekes)

Luc,

The picture I tried to attached is Depth_j+1<=sm_i,0<Depth_j.

 

Actually there is no problem in the first condition of "if...else..." block. I can get correct soil properties at depth of 5' if I get rid of second portion within "else". So I feel it is seemly not really numeric comparison issue since once the first condition is completed, "i" should be 5 (or depth should be 6ft). Why the second condition with "else" block come back to override the "i" of 4 (or depth at 5'). You can verify by removing the second block.

 

Thanks a lot

Shan

sshu
4-Participant
(To:sshu)

Thanks Luc. I think I got it.

LucMeekes
23-Emerald III
(To:sshu)

Ah, now I see it,

You would have expected that at a depth of 5 ft, the blow count would be 20, not 15, etc.

This is due to the numerical (in)accuracy. Your feet units are internally converted to metres (SI units). There is a numerical precision to any number that you can represent.

If you compare 5 ft with 5 ft you will find they are equal.

If you compare (4+1)*Li+Es-Eg with Depth0 (as you do in the Shaft_Matrix program), you will find they are not equal.

This is NOT a bug, it is a side-effect of numerical accuracy. YOU have to take appropriate measures to assure correct comparison, e.g. by making it less strict as in: (4+1)*Li+Es-Eg - Depth0 < TOL.

 

Success!
Luc

 

sshu
4-Participant
(To:LucMeekes)

how to write with Tal? there is no "And" operator in Mathcad. Here we have to use imperial unit system.

 

Thanks

 

LucMeekes
23-Emerald III
(To:sshu)

Your picture was lost, so I have no clue what you were trying to explain. What do you mean by 'Tal'?

You cannot successfully copy and paste a picture in this forum. You have to use the 'Photos' button, just above the edit pad to insert a picture (that you must have on file).

There is an AND (boolean) operator in Prime, Look it up in the operators list under 'Comparison', it looks like /\

(and the boolean OR is \/  )

 

Success!

Luc

 

Announcements

Top Tags