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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

pick the middle member of an array

payman
14-Alexandrite

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

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(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
25-Diamond I
(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
14-Alexandrite
(To:Werner_E)

Thank you Werner.

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.

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 III
(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

StuartBruff
23-Emerald III
(To:StuartBruff)

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

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.

Thanks Vladimir,

I think I need to upgrade my Prime version.

Mike

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

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
14-Alexandrite
(To:payman)

Thank you all gentlemen

Announcements

Top Tags