Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



maximum values in loops for 2d matrix
Posted:
Aug 19, 2014 6:43 AM


hello, i need for some defined times N=5 (i used while loop) ,to find the maximum values in a 2d matrix and save them each time so that the old max values not to be calculated again in the second repeat (for instance N=2). So i thought that i might need to delete the old max values before calculating the new ones , but having previously save them to a new matrix. Below i quote the code please take a look and advise ,thanks in advance.
while(N<=5) [rows,cols]=size(Sf); for i1=1:cols maximum(i1)=Sf(1,1); for j1=1:rows if Sf(j1,i1)>maximum(i1) %%max(Sf,[],1) maximum(i1)=Sf(j1,i1); %%max_rows=max(Sf); %%max_columns=max(max_rows); end end end N=N+1; end



