"Array indices must be positive integers or logical values"
古いコメントを表示
for i=1:n
disp(i)
ti(i+1)=ti(i)+dt;
x1i(i+1)=x1i(i)+dt(V1i(i))
x2i(i+1)=x2i(i)+dt(V2i(i))
Using, this code I get the error message shown in the subject line, even if i change the updating to x1i(i)= ... this doesn't fix the problem.
Any advice?
3 件のコメント
Antoni Garcia-Herreros
2023 年 3 月 22 日
Could you provide some more info on what size is your data (n,ti,dt,V1,V2)?
Rory Thiel
2023 年 3 月 22 日
Rory Thiel
2023 年 3 月 22 日
回答 (1 件)
Cris LaPierre
2023 年 3 月 22 日
編集済み: Cris LaPierre
2023 年 3 月 22 日
Your indices must be positive integer values (or logicals), as the error message states. It is therefore most likely either V1i(i) or V2i(i) are not returing an integer value, causing the error about invalid array indices when used to index into your variable dt.
a=1:3;
% This works
a(1)
% your error
a(1.5)
カテゴリ
ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!