Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
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....
I had an idea to try and split the matrix into column vectors and do it that way, as per the link below
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
Solved! Go to Solution.
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.
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.
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.