Index exceeds matrix dimensions error

1 Ansicht (letzte 30 Tage)
reza hamzeh
reza hamzeh am 12 Jan. 2020
Bearbeitet: Stijn Haenen am 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.

Akzeptierte Antwort

Stijn Haenen
Stijn Haenen am 12 Jan. 2020
Bearbeitet: Stijn Haenen am 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

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by