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 Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by