Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

MathCAD 15 - For a given value, find value greater than in a table and return a string in column 2.

Status
Not open for further replies.

DanCoyne

Structural
Joined
Aug 25, 2013
Messages
3
Location
AU
Hi all, new to these forums, stumbled upon looking for MathCAD help.

I have tried a couple of things without success so far. I have a 7x2 table like so:

7.09 HA28
8.37 HA32
11.24 HA36
13.75 HA40
17.12 HA45
22.02 HA50
29.3 HA60

For a given value calculated elsewhere, I want to be able to compare that value with column 1 and find the first value that is greater than the given value and return the text in column two.

So for example:

Given Value:
r1: 12.5

Table finds 13.75 >= 12.5

Output:
HA40

I've looked at the lookup functions but am not sure if it is able to/how to compare numerical values that do not match (finding a value greater than) then output a string format? Also considered that the may be a loop involved somewhere..

I have done something similar in excel before but am fairly new to MathCAD.

Any help would be appreciated.

Thanks
 
Another way I have tried is making two 7x1 vectors (M1 & M2) then using the following:

A1:= match(r1,M1) =

A2:= M.2.A1 =

Couple of problems with this, A1 does not make use of my greater than or equal to requirement ie. it only works when r1 is equal to one of the entries in A1

A2 uses the display tool. It is meant to return the entry in M2 corresponding to the integer entered however I need this to vary, it needs to be A1 really however it won't allow a non integer value, even though A1's answer is an integer.

As I said this doesn't work, it's just something I've tried so far. I'm sure there is a much cleaner way to achieve this.
 
This subject has been discussed in this forum before; please do a search.

TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529
 
Hey Occupant,

That code worked a treat. Thanks a bunch!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top