MATLAB Answers

Index exceeds matrix dimensions error

1 view (last 30 days)
reza hamzeh
reza hamzeh on 12 Jan 2020
Edited: Stijn Haenen on 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.

  0 Comments

Sign in to comment.

Accepted Answer

Stijn Haenen
Stijn Haenen on 12 Jan 2020
Edited: Stijn Haenen on 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

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.