Skip to main content
1-Visitor
September 10, 2015
Solved

pick the middle member of an array

  • September 10, 2015
  • 3 replies
  • 5890 views

Hello, I have an array of numbers. I don't know the number of members. I want to pick the member at the middle (or close to the middle if the number of members is even).

Is there any function in mathcad for doing this job? Could you help me with this?

Thank you

Best answer by Werner_E

Something like the built-in function median or something like the "half max index" as shown below?

Note that the value returned by median is not necessarily a number present in the vector but sometimes its the average of the two center values (when the vector is sorted).

3 replies

Werner_E25-Diamond IAnswer
25-Diamond I
September 11, 2015

Something like the built-in function median or something like the "half max index" as shown below?

Note that the value returned by median is not necessarily a number present in the vector but sometimes its the average of the two center values (when the vector is sorted).

payman1-VisitorAuthor
1-Visitor
September 11, 2015

Thank you Werner.

1-Visitor
September 11, 2015

An alternative for the condition when you have even members.

Clipboard01.jpg

Mike

25-Diamond I
September 11, 2015

Careful! Your routine just returns the index of the elements, not the vector elements themselves.

1-Visitor
September 11, 2015

Werner Exinger wrote:

Careful! Your routine just returns the index of the elements, not the vector elements themselves.

Well spotted Werner

Mike

payman1-VisitorAuthor
1-Visitor
September 11, 2015

Thank you all gentlemen