Effacer les filtres
Effacer les filtres

help how can I find the minimum number and return it's index in each row?

2 vues (au cours des 30 derniers jours)
maha ismail
maha ismail le 13 Nov 2014
Commenté : maha ismail le 13 Nov 2014
help how can I find the minimum number and return it's index in each row?
  1 commentaire
maha ismail
maha ismail le 13 Nov 2014
I have a matrix not a vector and I need the minimum value except 0 and position of minimum value in each row

Connectez-vous pour commenter.

Réponse acceptée

Manoj
Manoj le 13 Nov 2014
a=[8,2,3,4,5];
[b,ix]=min(a);
ix gives you the positions and b gives the minimum value
  4 commentaires
maha ismail
maha ismail le 13 Nov 2014
sorry dear I have a matrix not a vector I have a positive number and 0 I need to find the minimum value except 0 and I need to return the position of minimum value in each row ..but my program is not run..
maha ismail
maha ismail le 13 Nov 2014
dear manoj thanks alot for help me its a perfect solution but I need another update if the matrix has a zero value and the zero is the smallest value but I don't choose it I need more than zero and the smallest after zero

Connectez-vous pour commenter.

Plus de réponses (1)

Guillaume
Guillaume le 13 Nov 2014
To find the minimum of a row, use:
min(m, [], 2)
Probably, the simplest way to ignore 0s is to replace them with NaNs before calling min.
m(m == 0) = nan;
[mval, mcol] = min(m, [], 2);

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by