Index exceeds matrix dimensions error

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

Stijn Haenen
Stijn Haenen il 12 Gen 2020
Modificato: Stijn Haenen il 12 Gen 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

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by