stepwise function, or better?
Hi folks,
My problem is a simple one - calculate the vertical overburden stress in a soil mass. The simplified equation is just [ unit weight of soil ] * [ depth ]. However, in a layered system with a different unit weight for each layer, the calculation is best formed as the sum of the vertical stress increments. To me that looks like a stepwise function constructed as a series of IF-ELSEIF-ELSE statements as shown in my example below. It works but there is surely a more clever way.
Lets say the bottom of layer 1 is z1 and the stress is p1, and the stress at some mid-depth in layer 2, say z2, is delta_p2, such that the stress at the point in question is p(z2) = p1 + delta_p2. What is the most efficient way of structing that calculation as a function depth (z) so that it can be scaled to any number of layers. My best idea so far is an "If" function to evaluate the stress at the bottom of each layer plus the portion of the n-th layer at the target depth. Its cumbersome. In a 4 layer system, the function has 4 steps.
Obviously depth z and unit weight gamma are defined. They are each single column matrices. For depth, z_top is the depth to the top of each layer, and the unit weight is define similarly. In this case z is negative to indicate depth below ground surface.


