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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Determining Maximum Values per Row in a Matrix

AATaylor
5-Regular Member

Determining Maximum Values per Row in a Matrix

Hi, 

 

I would like to write a program that determines the maximum values per row in a i by j matrix.

 

I have written the program below, but I am struggling to get it to work automatically, without having to manually add in the number of columns in the max() function on line 3 - please see attached. I thought the second example in the attachment maxrows2(VEC) was the same as maxrows(VEC); however it seems not....maxrows.PNG

 

I had an idea to try and split the matrix into column vectors and do it that way, as per the link below 

 

https://community.ptc.com/t5/PTC-Mathcad-Questions/Need-to-select-the-maximum-of-two-column-matrices-and-return-as/m-p/334430#M130735

 

However I am also having trouble writing a program to automatically split an i by j matrix into j columns!

 

Any help would be greatly appreciated.

 

Kind regards

1 ACCEPTED SOLUTION

Accepted Solutions

I just stumbled over your question and while I am not sur if you still need the help, here it is.

Your maxrows2 will always return the last column of the input matrix.

Here is a solution which automatically will deal with any number of rows. As Mathcad 15 does not provide a row selector, we have to transpose the matrix and use the column selector.

b.png

View solution in original post

3 REPLIES 3

I just stumbled over your question and while I am not sur if you still need the help, here it is.

Your maxrows2 will always return the last column of the input matrix.

Here is a solution which automatically will deal with any number of rows. As Mathcad 15 does not provide a row selector, we have to transpose the matrix and use the column selector.

b.png

AATaylor
5-Regular Member
(To:Werner_E)

Yes, thank you - I hadn't found a solution for this, so I just did it the long way. This is really useful thank you.

Although, if you wouldn't mind explaining, what does the <c> operator do in M^<c>?

Many thanks and kind regards

the <c> operator is the column selector which I mentioned. You get it by typing Ctrl 6 or via the matric palette.

It returns the column number c, a column vector. So this column vector is fed into the max functions which returns the max number of that vector.

Mathcad 15 an below don't offer a row selector (Prime does - one of the few improvements in Prime) and thats the reason I had to transpose the matrix first.

B.png

Top Tags