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

Define Piecewise Function from Input Table

SOLVED
Participant

Define Piecewise Function from Input Table

All, 

 

I'm attempting to start what should be a simple geotechnical effective stress calculation. My first step is defining a soil unit weight profile as a function of depth (z) in an efficient and robust method. In the past, I've used "if statements" to control this however they are cumbersome and not very sophisticated. An example of what I've done in the past is shown on Page 2 of the attached worksheet. 

 

On Page 1 I attempted using "vlookup", however I ran into numerical issues and precision errors due to TOL...ideally, I would like to end up with a function that is as simple as the "vlookup" approach, but with the precision of the function defined by the "if statement". Any suggestions would be appreciated...I've attempted "for loops" and "while loops" without any success. 

 

Thanks in advance!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Define Piecewise Function from Input Table

The lack of precision of "match", "lookup", etc. (especially when used with units) can be very annoying quite often.

I would suggest implementing your own specialized lookup function to do the job better.

B.png

 

12 REPLIES 12

Re: Define Piecewise Function from Input Table

Hi,

 

Look up linear interpolation in help.  You can arrange a matrix of depths and values to interpolate.

For example here is one that changes from compass direction to polar plot direction.  The tolerance is built in.

Capture.JPG

Re: Define Piecewise Function from Input Table

The lack of precision of "match", "lookup", etc. (especially when used with units) can be very annoying quite often.

I would suggest implementing your own specialized lookup function to do the job better.

B.png

 

Re: Define Piecewise Function from Input Table

Wouldn't

2018-10-03_13-46-02.png

be a simpler but equivalent solution to your compass problem?

 

Re: Define Piecewise Function from Input Table

I can't demonstrate it because "linterp" is a "premium function", but this should do what you want:

Capture.PNG

Re: Define Piecewise Function from Input Table

Or, you look up the help info on VLOOKUP and find that there's a way around TOL dependency:

LM_20181003_Vlookup.png

 

Success!
Luc

Highlighted

Re: Define Piecewise Function from Input Table

Nice idea and it even can be streamlined a little bit:

B.png

Drawback may be that it fails for input values greater or equal to 30 ft.

 

Re: Define Piecewise Function from Input Table

Thanks so much for the assistance on this. There were a lot of great solutions to this question, but implementing a custom look-up function seemed to be the most efficient method in defining my profile of soil properties as a function of depth. 

 

Thanks again!

Re: Define Piecewise Function from Input Table

Does anybody here use "SMath Studio"? I'm trying to recreate this sheet using SMath, but can't seem to get the same lookup function to work out (see attached screenshot). SMath - Function Error.JPG

Re: Define Piecewise Function from Input Table

Attach the sheet... NOT just a picture.

 

Luc