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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

lookup from a table in mathcad prime 8

GA_10603334
4-Participant

lookup from a table in mathcad prime 8

Hi Mathcaders,

I am alittle bit confused on how to use lookup on mathcad prime 8. 

problem statement:

I have a table of containing Steel section name and elastic section modulus as given below: 

GA_10603334_1-1681826751725.png

In my work, I have to calculate an elastic section modulus and match with values in the table and choose the profile with the nearest upper value. 

 

My trials:

1. I used the following expression: 

GA_10603334_0-1681886933282.png

It only compares the first digit. The answer is always AZ12 until I increasesd the calculated value to more than 2000. 

 

2. I used the following expression ( I got it from the internet)

GA_10603334_1-1681887585904.png

The answer is the same as before.

 

 

Any help please? 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

There is nothing wrong with your usage of lookup.
Whats wrong is the way how this function is implemented in Prime (same problem in real Mathcad, too).

As Terry already explained, the various "lookup" functions and also "match" are using the value of the system variable TOL to decide if two values are equal.  The default value for TOL is 10^-3.

When using quantities with units, Prime stores them always in their standard unit and not in the unit you use when you define them.

For volumes the default unit for display are liter, but I guess that the values internally are stored using the default length unit meter. So the first entry in the W-table is 0.0012 (m^3) and the value you look for is 0.001205 (m^3). Within a tolerance of 10^-3 they are considered equal and thats the reason 1200 cm^3 is considered "greater or equal" to 1205 cm^3.


I always found this behaviour of the match and lookup function to be wrong and usually try to avoid these functions when using quantities with units or with very small values and wrote small functions which loop through the matrices using the boolean comparisons (=,<,>) to do the job.

Werner_E_4-1681904218802.png

 

Another option is what Terry had shown. Either decrease TOL or just make the values larger by multiplying them with a large number.
Dividing by the unit liter is equal to multiplying the numbers by 1000 and so Prime compares 1.2 to 1.205 and decides that 1.2 is not equal or larger.

I would prefer to divide by the unit used (cm^3) so you compare the magnitudes you see in the table - 1200 to 1205. But thats a matter of personal taste, I guess.

Werner_E_0-1681902520317.png

 

You may also just multiply the values by a number large enough to be sure it makes their difference larger than TOL

Werner_E_1-1681902669445.png

 

 

View solution in original post

6 REPLIES 6

Hi,

The function that is preferable is match() not lookup():  The match function uses TOL variable and in cm^3 the tolerances are interfering with the result.  Either change the TOL variable or as I have done here used Litres.  Reducing this TOL value makes the match more strict; increasing it makes the match less strict.

Capture3.JPG

Cheers

Terry

There is nothing wrong with your usage of lookup.
Whats wrong is the way how this function is implemented in Prime (same problem in real Mathcad, too).

As Terry already explained, the various "lookup" functions and also "match" are using the value of the system variable TOL to decide if two values are equal.  The default value for TOL is 10^-3.

When using quantities with units, Prime stores them always in their standard unit and not in the unit you use when you define them.

For volumes the default unit for display are liter, but I guess that the values internally are stored using the default length unit meter. So the first entry in the W-table is 0.0012 (m^3) and the value you look for is 0.001205 (m^3). Within a tolerance of 10^-3 they are considered equal and thats the reason 1200 cm^3 is considered "greater or equal" to 1205 cm^3.


I always found this behaviour of the match and lookup function to be wrong and usually try to avoid these functions when using quantities with units or with very small values and wrote small functions which loop through the matrices using the boolean comparisons (=,<,>) to do the job.

Werner_E_4-1681904218802.png

 

Another option is what Terry had shown. Either decrease TOL or just make the values larger by multiplying them with a large number.
Dividing by the unit liter is equal to multiplying the numbers by 1000 and so Prime compares 1.2 to 1.205 and decides that 1.2 is not equal or larger.

I would prefer to divide by the unit used (cm^3) so you compare the magnitudes you see in the table - 1200 to 1205. But thats a matter of personal taste, I guess.

Werner_E_0-1681902520317.png

 

You may also just multiply the values by a number large enough to be sure it makes their difference larger than TOL

Werner_E_1-1681902669445.png

 

 

Hi,

I prefer match() over lookup() as it returns an index not a value.  The index can then be reused to get the correct matching value of I and A by using the selected row.index directly.

If you use lookup you have a value but you need to lookup again for matching I and A.

With a Universal Beam Table for instance there are 38 columns with relevant design information.  One index from match() on section modulus can be used to pick all matching 37 values using the calculated matching index,

Cheers

Terry

I agree that the advantage of "match" is that you also can get the other values of the found profile using the index returned without having to use "lookup" over and over again to do the job.

But @GA_10603334   wrote that he was just looking for the profile (name) and I didn't want to give him the impression that he did anything wrong by using "lookup" 😉

Thank you so much. Looking for the indices and fetching other values using these indices  is going to be next next question. You saved me 😉  

 

Also thanks to the tip about TOL. Reducing TOL to 10^-8 gives the answer I was expecting. 

GA_10603334
4-Participant
(To:Werner_E)

Thank you so much the inputs and also the clarification on how the functions work.  Placing TOL:=10^-8 at top gives the answer I was expecting. 

Top Tags