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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Finding the Max Value from Part of a Matrix

JJ_9094500
4-Participant

Finding the Max Value from Part of a Matrix

Please see the attached file. I need a simple and elegant solution for finding the max value from part of a single column matrix. Thanks

JJ_9094500_0-1643366753873.png

 

ACCEPTED SOLUTION

Accepted Solutions
StuartBruff
23-Emerald III
(To:JJ_9094500)

Here are some variants on the answers already given plus an additional one that allows you to choose whichever elements you want from A.

 

Note that the functions were written in Mathcad Prime Express 7.  Express does not have programming and so breaks a function down into a sequence of successive (functional) steps.

 

StuartBruff_0-1643391811477.png

 

StuartBruff_1-1643391869900.png

StuartBruff_3-1643392064988.png

 

 

Mathcad Prime Express 7 worksheet attached.

 

Stuart

 

 

 

 

View solution in original post

9 REPLIES 9
ttokoro
20-Turquoise
(To:JJ_9094500)

image.pngimage.png

Hi,

MartinHanak_0-1643377767233.png

 


Martin Hanák
LucMeekes
23-Emerald III
(To:JJ_9094500)

Or, in one go, and irrespective of the value of ORIGIN:

LucMeekes_1-1643381972237.png

Prime4 file attached.

 

Success!
Luc

 

KevinFinity_0-1643391505699.png

 

StuartBruff
23-Emerald III
(To:JJ_9094500)

Here are some variants on the answers already given plus an additional one that allows you to choose whichever elements you want from A.

 

Note that the functions were written in Mathcad Prime Express 7.  Express does not have programming and so breaks a function down into a sequence of successive (functional) steps.

 

StuartBruff_0-1643391811477.png

 

StuartBruff_1-1643391869900.png

StuartBruff_3-1643392064988.png

 

 

Mathcad Prime Express 7 worksheet attached.

 

Stuart

 

 

 

 

Hello, I can confirm that submatrix() and programs are applicable and are the intended approach.

 

However, getting back to initial request to "simple and elegant solution": Utilizing simple Mathcad definition capabilities, please compare this:

 

StuartBruff
23-Emerald III
(To:MichaelW)

See the second line in my response - the shuffle was just there to randomize the data for test purposes (and provide a function that is potentially useful in other circumstances).  

 

https://community.ptc.com/t5/PTC-Mathcad/Finding-the-Max-Value-from-Part-of-a-Matrix/m-p/775291/highlight/true#M199539

 

(the image is just a continuation of the OP's original)

 

Stuart

Well I see. Thank you for the reminder.

Seems that the initial post caused a lot of elegant and other related solutions.

I'd say that this solves the issue anyway.

What you think?

StuartBruff
23-Emerald III
(To:MichaelW)


@MichaelW wrote:

Well I see. Thank you for the reminder.

Seems that the initial post caused a lot of elegant and other related solutions.

I'd say that this solves the issue anyway.

What you think?


On the surface, I agree that it would appear closed.

 

However, I'm always curious as to what the source of the problem is.  For example, why the max of the first 3 of 20 items, and why "matrix" instead of "vector"?  Sometimes, there's a bit more to the story that can invalidate the proposed solutions or make them just a subset - eg, the user might want to specify a column of a matrix or realize they need the location of the item as well.

 

Stuart

Announcements

Top Tags