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

1 vue (au cours des 30 derniers jours)
A= 5*5 size matrix
for m=1:5;
for n=1:5;
line 7-> E= A(m,n);
disp (E).

Réponse acceptée

Awais Saeed
Awais Saeed le 21 Août 2021
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 commentaires
Shubham Kumar
Shubham Kumar le 21 Août 2021
I want to print all the elements of the matrix one by one.
Awais Saeed
Awais Saeed le 21 Août 2021
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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Types 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