cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

pick the middle member of an array

payman
13-Aquamarine

pick the middle member of an array

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

1 ACCEPTED SOLUTION

Accepted Solutions
Werner_E
24-Ruby V
(To:payman)

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).

View solution in original post

15 REPLIES 15
Werner_E
24-Ruby V
(To:payman)

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).

payman
13-Aquamarine
(To:Werner_E)

Thank you Werner.

MikeArmstrong
5-Regular Member
(To:payman)

An alternative for the condition when you have even members.

Clipboard01.jpg

Mike

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

MikeArmstrong
5-Regular Member
(To:Werner_E)

Werner Exinger wrote:

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

Well spotted Werner

Mike

StuartBruff
23-Emerald II
(To:Werner_E)

Gentlemen,

Please accept my due apologies for the flippancy of the attached worksheet.  I'm in a flippant mood as I have about a dozen worksheets on the go simultaneously, and I can't decide which one to prioritize as I'm also in an Ooh! Shiny! mood.

As I have posted it in such a flippant manner, the worksheet is bound to be littered with errors ...

Stuart

Oddly, it doesn't look quite as flippant in Prime ...

MikeArmstrong
5-Regular Member
(To:StuartBruff)

Just realised I have not updated to Prime 3.1 and cannot open your worksheet

Mike

Mike Armstrong wrote:

Just realised I have not updated to Prime 3.1 and cannot open your worksheet

Mike

Hopefully, if you've got an earlier Prime, the M15 sheet should convert readily enough - I don't think there are any major surprises or Primeifications.

I can't quite put my finger about, but Prime 3.1 seems to irritate me less than I recollect Prime 3 doing; I think it may be because it runs small worksheets faster (subjectively, at least, if not objectively as well).  Or maybe it's just because I've got an i7 with 8 GiB RAM instead of my old Core2 4 GiB PC.  I do notice, and approve of, Prime 3.1's ability to deal with larger arrays than M15 can.

Stuart

Mike,

Please find in attachment PDF and XPS version of this Prime worksheet.

MikeArmstrong
5-Regular Member
(To:VladimirN)

Thanks Vladimir,

I think I need to upgrade my Prime version.

Mike

MikeArmstrong
5-Regular Member
(To:StuartBruff)

How about we return the original vector with the values marked. Not what was requested, but better than doing work

Clipboard01.jpg

Mike

Mike Armstrong wrote:

How about we return the original vector with the values marked. Not what was requested, but better than doing work

Amen, Brother!  In fact, I propose that the Community Spelling Censor adds that particular 4-letter Anglo-Saxon word to its List!

Stuart

MikeArmstrong
5-Regular Member
(To:StuartBruff)

StuartBruff wrote:

Mike Armstrong wrote:

How about we return the original vector with the values marked. Not what was requested, but better than doing work

Amen, Brother!  In fact, I propose that the Community Spelling Censor adds that particular 4-letter Anglo-Saxon word to its List!

Stuart

I second that.....

Mike

payman
13-Aquamarine
(To:payman)

Thank you all gentlemen

Top Tags