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.

 채택된 답변

Stijn Haenen
Stijn Haenen 2020년 1월 12일
편집: Stijn Haenen 2020년 1월 12일

0 개 추천

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개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

질문:

2020년 1월 12일

편집:

2020년 1월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by