Data comparison and selection the smallest

1 vue (au cours des 30 derniers jours)
stelios loizidis
stelios loizidis le 11 Juin 2020
Commenté : stelios loizidis le 11 Juin 2020
Hello. I have a matrix A which has size of 24X5. I want each row in matrix A to be selected the smallest and stored in matrix B. Below is the code I wrote but it does not work (error: Index in position 2 exceeds array bounds (must not exceed 5)).
for i=1:24
for j=1:5
if A(i,j)<A(i,j+1)
B(i)=A(i)
else
B(i)=A(j+1)
end
end
end
Your help is very important!!!!

Réponse acceptée

KSSV
KSSV le 11 Juin 2020
You can read about the function min
  1 commentaire
stelios loizidis
stelios loizidis le 11 Juin 2020
Correctly. Thank you very much!!!!

Connectez-vous pour commenter.

Plus de réponses (1)

madhan ravi
madhan ravi le 11 Juin 2020
Modifié(e) : madhan ravi le 11 Juin 2020
  1 commentaire
stelios loizidis
stelios loizidis le 11 Juin 2020
it works. Thank you very much!!!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Creating and Concatenating Matrices 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