Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Array used to look up a value in matrix 1

Status
Not open for further replies.

REBSE

Structural
Feb 3, 2005
16
I have attached a simple file to help illustrate my question. I have the array Wui that gives input values. I need these values to help create another array with the results from Weight_of_Unit. Is this even able to be done and if so, how?

Ryan Erick Broomé, S.E., P.E.
 
Replies continue below

Recommended for you

Yes, Mathcad can do this quite easily using the one of the lookup functions, vlookup.

By default, Mathcad indexes arrays starting with zero for the first row or column. If you want to start with one instead, set the built-in ORIGIN to 1. You can either do this from the Tools/Worksheet Ooptions dialog box or you can set its value in the worksheet ... I prefer to do the latter as it makes it more obvious to others.

The function vlookup(z,m,c) looks for value z in the first column of array m and, for each row where it is found, returns the corresponding values in column c.

Note: in your original worksheet, you had A.i rather than A[i, hence the error as the range variable should (usually) appear on the left hand side of a definition if it's on the right hand side.
 
 http://files.engineering.com/getfile.aspx?folder=1ed06fc2-c1da-4651-a383-af6ad908a5be&file=Lookup_Question.mcd
lexcognito,



Note: in your original worksheet, you had A.i rather than A[i, hence the error as the range variable should (usually) appear on the left hand side of a definition if it's on the right hand side.


Wow! How did you figure that out??! Onscreen, those two look the same to me. Only after reading your post, did I try each one out, and you are correct. I'll have to remember this for future Mathcad work.

I give you a sar for that.


chichuck
 
chichuck said:
Note: in your original worksheet, you had A.i rather than A[i, hence the error as the range variable should (usually) appear on the left hand side of a definition if it's on the right hand side.

Wow! How did you figure that out??! Onscreen, those two look the same to me. Only after reading your post, did I try each one out, and you are correct. I'll have to remember this for future Mathcad work.

It's a common occurrence and quite easy to inadvertently type '.' instead of '[', so I tend to look for it when I see odd error messages. The trick is to click on an expression and you should note a slight flicker as Mathcad displays it as 'A.i' rather than 'Ai. In addition, the editing line is limited to just the A when it's a vector and the whole of A.i when its a subscripted name.

I give you a sar for that.

Thanks.
 
Thanks so much for your help. That is exactly what I needed.

Ryan Erick Broomé, S.E., P.E.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor