×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

vlookup returns a vector - need a scalar
2

vlookup returns a vector - need a scalar

vlookup returns a vector - need a scalar

(OP)
When I use vlookup to get the nth value of a single column array, it returns a vector, which I can't use in a subsequent vlookup function.  

My arrays are one column by 10 rows, with one arry being the root areas and the other array being the bolt size.

I calculate a minimum area, then use lookup in an array of bolt root areas, then return the bolt size.  

vlookup( calculated area , bolt root areas , bolt size )

vlookup seems to return the next highest bolt, which is what I want.

Then I want to use the bolt size in a vlookup to get the actual root area to then calculate the bolt strength.  But, Mathcad chokes on the use of the results from the first vlookup because it is a vector of one valur but it has to be a scalar.

How to convert?  Or do this easier?

RE: vlookup returns a vector - need a scalar

guessing, can't you use something like

result:vlookup(whatever)

newlookup:result[1

to extract the scalar from the vector.

Cheers

Greg Locock

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.

RE: vlookup returns a vector - need a scalar

(OP)
I'm using Result:=lookup(X,Y,Z) and it returns Result=(value) including the parenthesis.  Then when I try to use NewVariable:=lookup(Result,Y,Z) it says error because "Result" is an array and needs to be a scalar.

RE: vlookup returns a vector - need a scalar

2
Greg's method is correct.

Result:lookup(X,Y,Z)

Will always give you a matrix (as you pointed out).  If there is only one match it is still a matrix (1x1), if there is more then one match then you will get a nx1 matrix.  The way to end up with a scalar in your case is:

Result:lookup(X,Y,Z)[0

Assuming the origin is zero.  The [0 selects the first element of the matrix for the result, which is a scalar.  If your origin is 1, then replace that with [1.

Peter

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close