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!

Find element in Vector

Status
Not open for further replies.

zdas04

Mechanical
Joined
Jun 25, 2002
Messages
10,274
Location
US
In MatchCad 14 I have an array with one column and 2000 rows. If I do x=min(Array) I get the minimum value. I want to know the row number of that minimum value. Is there a reasonable way to extract it?

David Simpson, PE
MuleShoe Engineering

"Belief" is the acceptance of an hypotheses in the absence of data.
"Prejudice" is having an opinion not supported by the preponderance of the data.
"Knowledge" is only found through the accumulation and analysis of data.
 
It's a bit convoluted:

k:0;rows(Array)-1 indices corresponding to the rows of Array

row[k:k -- creates a vector of row numbers corresponding to the rows of Array

lookup(x,Array,row)[0 -- looks up x in Array, and returns the value in row with the same column and row; the [0 is because lookup returns an array with a single element

TTFN
faq731-376
7ofakss
 
Try "match(min(x),x)ORIGIN" where [ = index operator and ORIGIN is usually 0 (Mathcad default) or 1.

This will (should!) return the index of the minimum value of x
 
Right after I posted, my son and his family arrived and this is the first time I've been back at the computer. I'll try these ideas once they go back to Texas.

Thanks for the help so far.

David Simpson, PE
MuleShoe Engineering

"Belief" is the acceptance of an hypotheses in the absence of data.
"Prejudice" is having an opinion not supported by the preponderance of the data.
"Knowledge" is only found through the accumulation and analysis of data.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top