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?
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
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
RE: vlookup returns a vector - need a scalar
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