From: Snow White on 22 Apr 2010 15:09 Hello, I have a matrix (mxn) and I have to Normalize the matrix by scaling its rows so that they have equal norms. I have checked balance but that normalizes both row and columns and i have also checked norm. is there a way of doing it? Bye
From: Roger Stafford on 22 Apr 2010 17:14 "Snow White" <gulesaman(a)gmail.com> wrote in message <hqq6t1$cui$1(a)fred.mathworks.com>... > Hello, > > I have a matrix (mxn) and I have to Normalize the matrix by scaling its rows so that they have equal norms. > > I have checked balance but that normalizes both row and columns and i have also checked norm. is there a way of doing it? > > Bye Well then find the norm of each row and divide the row by that. That will make each row norm equal to one. Is that what you had in mind? M = M./repmat(sqrt(sum(M.^2,2)),1,n); Roger Stafford
From: Snow White on 22 Apr 2010 18:26 Hello, Thank you. what i dont get is that you are suming and doing all operations across the second dimension which is the column. should not they be across the first dimension the rows?:S Bye "Roger Stafford" <ellieandrogerxyzzy(a)mindspring.com.invalid> wrote in message <hqqe7d$i0q$1(a)fred.mathworks.com>... > "Snow White" <gulesaman(a)gmail.com> wrote in message <hqq6t1$cui$1(a)fred.mathworks.com>... > > Hello, > > > > I have a matrix (mxn) and I have to Normalize the matrix by scaling its rows so that they have equal norms. > > > > I have checked balance but that normalizes both row and columns and i have also checked norm. is there a way of doing it? > > > > Bye > > Well then find the norm of each row and divide the row by that. That will make each row norm equal to one. Is that what you had in mind? > > M = M./repmat(sqrt(sum(M.^2,2)),1,n); > > Roger Stafford
From: Snow White on 23 Apr 2010 07:56 ok i get it now.. thank you. "Roger Stafford" <ellieandrogerxyzzy(a)mindspring.com.invalid> wrote in message <hqqo9e$451$1(a)fred.mathworks.com>... > "Snow White" <gulesaman(a)gmail.com> wrote in message <hqqids$25b$1(a)fred.mathworks.com>... > > Thank you. what i dont get is that you are suming and doing all operations across the second dimension which is the column. should not they be across the first dimension the rows?:S > -------------------- > When you stated originally that you were asking for "scaling its rows so that they have equal norms" it is my understanding (and I think that of most other people in CSSM) that you were referring to the norms of *horizontal* rows in the matrix, and by columns you would mean *vertical* columns. If that is what you meant, then for each row the first dimension should stay fixed while the second dimensions varies throughout the row, and the reverse is true for any column. Therefore in adding up the squares of the terms in a row, you want to do the summation along the second dimension. For each row this will give a single sum quantity, and for all the rows a single column of sums. Taking their square roots gives you the needed scaling factors for the corresponding rows. The 'repmat' was done, again along the second dimension, to allow multiplying these scaling factors by entire rows, > (though I believe there may be better ways of accomplishing this last operation.) > > Roger Stafford
From: Roger Stafford on 22 Apr 2010 20:06 "Snow White" <gulesaman(a)gmail.com> wrote in message <hqqids$25b$1(a)fred.mathworks.com>... > Thank you. what i dont get is that you are suming and doing all operations across the second dimension which is the column. should not they be across the first dimension the rows?:S -------------------- When you stated originally that you were asking for "scaling its rows so that they have equal norms" it is my understanding (and I think that of most other people in CSSM) that you were referring to the norms of *horizontal* rows in the matrix, and by columns you would mean *vertical* columns. If that is what you meant, then for each row the first dimension should stay fixed while the second dimensions varies throughout the row, and the reverse is true for any column. Therefore in adding up the squares of the terms in a row, you want to do the summation along the second dimension. For each row this will give a single sum quantity, and for all the rows a single column of sums. Taking their square roots gives you the needed scaling factors for the corresponding rows. The 'repmat' was done, again along the second dimension, to allow multiplying these scaling factors by entire rows, (though I believe there may be better ways of accomplishing this last operation.) Roger Stafford
|
Pages: 1 Prev: How to add a picture in the GUI? Next: syntax to use Parfor for "for loops " |