Hi I have m by n matrix,I want to find the index of the max. of each column.It can be found by [i j]:max(x,[],2).this gives the index of max of each column in vector i.I want if there is a repetion in vector i to be reset to 0.thanks
Infos
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Afficher commentaires plus anciens
Hi I have m by n matrix,I want to find the index of the max. of each column.It can be found by [i j]:max(x,[],2).this gives the index of max of each column in vector i.I want if there is a repetion in vector i to be reset to 0.thanks
Réponses (1)
Azzi Abdelmalek
le 11 Nov 2013
Modifié(e) : Azzi Abdelmalek
le 11 Nov 2013
m=[1 2 3;0 5 6;2 1 7;0 4 9]
[ii,jj]=max(m)
%[ii ji]=max(x,[],2) gives the max of each row
6 commentaires
yousef Yousef
le 11 Nov 2013
Modifié(e) : Azzi Abdelmalek
le 11 Nov 2013
Azzi Abdelmalek
le 11 Nov 2013
Ok, if 2 is repeated, what do you want to do?
Azzi Abdelmalek
le 11 Nov 2013
Maybe you want
r=randi(500,10,20);
[ii jj]=max(r)
[kk,ee]=unique(jj,'stable') ;
idx=zeros(1,numel(jj));
idx(ee)=kk
yousef Yousef
le 11 Nov 2013
yousef Yousef
le 11 Nov 2013
Azzi Abdelmalek
le 11 Nov 2013
No, you are looking for the max of each row, to find the maximum of each column
[ii ,jj]=max(r)
%or
[ii, jj]=max(r,[],1)
Cette question est clôturée.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!