Skip to main content
16-Pearl
October 8, 2016
Solved

Help with a step function

  • October 8, 2016
  • 1 reply
  • 2615 views

I'm stacking different plates and need to know a property (modulus) at any given height depending on which plate that height falls into.  I toyed with lookups, matches and ifs but the only thing I got to work is shown here.  It does work, but it doesn't seem very efficient for what I thought was a simple problem.  I'm betting there is a very elegant solution.  I'd appreciate any improvements. Thanks.

(Prime 3.1)

pic3.jpg

Best answer by Werner_E

AlvaroDíaz wrote:

In Prime can you use TOL as local inside Yng function?

Unfortunately this would have not the desired effect.

The way equality is implemented in the match and lookup functions is very bad and often confusing. In many cases its better to write ones own routine doing the job in a better .

As we have the modifier "near" (also available in Mathcad 15 if we use Lookup with capital L) I see no need to limit the equality to a range with tolerance TOL. Those functions should use full numeric precision when comparing numbers. Probably one could add a tolerance as function argument (maybe only in conjunction with "near") .

Fortunately match and lookup are rather easy to implement in a better way, with better error handling, etc. But it sure should not be necessary that we do that ourself.

Regards Werner

P.S.: Here is an alterative to my former "Yng" which does not depend on the value of TOL and I guess that now the result at the borders of the range are correct, corresponding to the routine provided by dferry. Also there is no need for the separate calculation of the vector height.

1 reply

25-Diamond I
October 8, 2016

Maybe something like the following

12-Amethyst
October 9, 2016

Hi Werner.

In Prime can you use TOL as local inside Yng function?

Best regards.

Alvaro.

Werner_E25-Diamond IAnswer
25-Diamond I
October 9, 2016

AlvaroDíaz wrote:

In Prime can you use TOL as local inside Yng function?

Unfortunately this would have not the desired effect.

The way equality is implemented in the match and lookup functions is very bad and often confusing. In many cases its better to write ones own routine doing the job in a better .

As we have the modifier "near" (also available in Mathcad 15 if we use Lookup with capital L) I see no need to limit the equality to a range with tolerance TOL. Those functions should use full numeric precision when comparing numbers. Probably one could add a tolerance as function argument (maybe only in conjunction with "near") .

Fortunately match and lookup are rather easy to implement in a better way, with better error handling, etc. But it sure should not be necessary that we do that ourself.

Regards Werner

P.S.: Here is an alterative to my former "Yng" which does not depend on the value of TOL and I guess that now the result at the borders of the range are correct, corresponding to the routine provided by dferry. Also there is no need for the separate calculation of the vector height.