matrix - Find the largest value of each row in Matlab and divide each number in that row by the number -


i have 133120x4 matrix in matlab.

i find largest value in each row, , divide every element in row particular value.

do need use sort of loop? example: find amount of rows in matrix (133120), , iterate loop amount of times, go row row , use max function return largest value in row, , divide each element in row returned value max.

or there quicker way of doing this?

thanks

edit (for clarification):

lets call 133120x4 matrix a. want divide every element in row largest value in row. since max , element-division vectorized, solution be:

a_normal = / max(a)

resulting in 133120x4 matrix, within each row, largest value 1.

is correct? edit: not correct, , still trying figure out solution. community appreciated

compute maximum max, repeat result n(=4) times there 1 per each element , element wise division !

newmat=mat./repmat(max(mat,[],2),[1 size(mat,2)]);] 

or in r2016b or newer

newmat=mat./max(mat,[],2); 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -