Getting error message ' Index in position 1 exceeds array bounds ( must not exceed 4), error in line 7.

3 ビュー (過去 30 日間)
A= 5*5 size matrix
for m=1:5;
for n=1:5;
line 7-> E= A(m,n);
disp (E).

採用された回答

Awais Saeed
Awais Saeed 2021 年 8 月 21 日
You are storing only one element in E. Perhaps you want to copy elements of A into E element by element.
A = magic(5)
for m=1:1:size(A,1)
for n=1:1:size(A,2)
E(m,n)= A(m,n);
end
end
disp(E)
  2 件のコメント
Shubham Kumar
Shubham Kumar 2021 年 8 月 21 日
I want to print all the elements of the matrix one by one.
Awais Saeed
Awais Saeed 2021 年 8 月 21 日
A = magic(5)
for m=1:1:size(A,1)
for n=1:1:size(A,2)
E= A(m,n);
disp(E)
end
end

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by