Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

vlookup returns a vector - need a scalar 2

Status
Not open for further replies.

IFRs

Petroleum
Nov 22, 2002
4,658
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?
 
Replies continue below

Recommended for you

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.
 
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.
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor