Data comparison and selection the smallest

조회 수: 2 (최근 30일)
stelios loizidis
stelios loizidis 2020년 6월 11일
댓글: stelios loizidis 2020년 6월 11일
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!!!!

채택된 답변

KSSV
KSSV 2020년 6월 11일
You can read about the function min

추가 답변 (1개)

madhan ravi
madhan ravi 2020년 6월 11일
편집: madhan ravi 2020년 6월 11일

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by