Index exceeds matrix dimensions error

조회 수: 1 (최근 30일)
reza hamzeh
reza hamzeh 2020년 1월 12일
편집: Stijn Haenen 2020년 1월 12일
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일
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개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by