Find max of matrix without using built in function.
Afficher commentaires plus anciens
I want to find the "max(a)" without actually using the built in "max" function.
2 commentaires
Roland
le 4 Mai 2011
Sean de Wolski
le 4 Mai 2011
We won't do your homework for you. What have you tried so far.
Réponse acceptée
Plus de réponses (2)
Sean de Wolski
le 4 Mai 2011
the_max = -min(-(a(:)))
2 commentaires
Roland
le 4 Mai 2011
Sean de Wolski
le 4 Mai 2011
the_max = a(a==-min(-(a(:))))
There!
Adrien Leygue
le 4 Mai 2011
0 votes
The following code will extract the minimum over each column. No loop no max no min and of course not optimal. Feel free to adapt it to other purposes:
S = A((repmat(eye(size(A,1)),[1 size(A,1)]) *(kron(A,ones(size(A,1),1)) < kron(ones(size(A,1),1),A)))==0)'
A.
Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!