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 日

0 投票

You can read about the function min

1 件のコメント

stelios loizidis
stelios loizidis 2020 年 6 月 11 日
Correctly. Thank you very much!!!!

サインインしてコメントする。

その他の回答 (1 件)

madhan ravi
madhan ravi 2020 年 6 月 11 日
編集済み: madhan ravi 2020 年 6 月 11 日

0 投票

5-1

1 件のコメント

stelios loizidis
stelios loizidis 2020 年 6 月 11 日
it works. Thank you very much!!!

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange で MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by