Index exceeds matrix dimensions error

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.

 Respuesta aceptada

Stijn Haenen
Stijn Haenen el 12 de En. de 2020
Editada: Stijn Haenen el 12 de En. de 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

Más respuestas (0)

Categorías

Preguntada:

el 12 de En. de 2020

Editada:

el 12 de En. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by