How to get the max values of each row in each matrix

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.
zcmcgurk
Posts: 5
Joined: Sat Nov 29, 2014 10:40 am

How to get the max values of each row in each matrix

Unread post by zcmcgurk »

So I am having a problem finding out how to get the maximum value in each row of a matrix. So for example say I had a 3x3 matrix with the first row being 1,2,3. The second row is 3,2,1 and finally the third row is 2,1,3. I would like to get a 3x1 vector that has values of 3,3,3.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: How to get the max values of each row in each matrix

Unread post by TomDoan »

compute [rect] x=%ranmat(3,3)
*
dec vect rowmax(%rows(x))
ewise rowmax(i)=%maxvalue(%xrow(x,i))
zcmcgurk
Posts: 5
Joined: Sat Nov 29, 2014 10:40 am

Re: How to get the max values of each row in each matrix

Unread post by zcmcgurk »

Thank you
Post Reply