How to call a column in a vector

10 vues (au cours des 30 derniers jours)
David Zhang
David Zhang le 12 Oct 2016
Commenté : James Tursa le 12 Oct 2016
suppose we have vector (v) v= [1 5 3 0 7]
and I want to find the minimum value
min(v)
I will get 0, but what I want to know is how can I print out the column number? In this case, the column number where the minimum value (0) is located is 4, but how can I make matlab display the column number to me?

Réponse acceptée

James Tursa
James Tursa le 12 Oct 2016
Modifié(e) : James Tursa le 12 Oct 2016
Get the 2nd output argument returned from the min function:
[value,column] = min(v);
  2 commentaires
David Zhang
David Zhang le 12 Oct 2016
Ok and how would I print it in a message such as "the winner is contestant (column number)"?
James Tursa
James Tursa le 12 Oct 2016
fprintf('The winner is contestant %d\n',column);

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Historical Contests dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by