Help with a step function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Help with a step function
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)
Solved! Go to Solution.
- Labels:
-
Other
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Maybe something like the following
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi Werner.
In Prime can you use TOL as local inside Yng function?
Best regards.
Alvaro.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
