Index exceeds matrix dimensions error

1 vue (au cours des 30 derniers jours)
reza hamzeh
reza hamzeh le 12 Jan 2020
Modifié(e) : Stijn Haenen le 12 Jan 2020
hi. plz help me to fix this error.
t{1}=0;
for n=1:10
if n/2>2
t{n}=t{n}+1
end
end
% error: Index exceeds matrix dimensions.

Réponse acceptée

Stijn Haenen
Stijn Haenen le 12 Jan 2020
Modifié(e) : Stijn Haenen le 12 Jan 2020
You should use ( and ) not { and }.
Try this code:
t=zeros(10,1);
for n=1:10
if n/2>2
t(n)=t(n-1)+1
end
end

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by