index exceeds matrix dimensions error
古いコメントを表示
Here is some code i've been working on and i keep getting the "index exceeds matrix dimension" error
%Calculate Trajectory
v = 200;
theta = 20;
g = 32.2;
i = 0;
t(1) = 0;
h(1) = 0;
x(1) = 0;
while(h >= 0)
i=i+1;
h(i) = v.*(t(i)).*sind(theta)-1/2.*g.*(t(i)).^2;
x(i) = v.*(t(i)).*cosd(theta);
t(i) = t + .1;
h=h(i);
end
採用された回答
その他の回答 (1 件)
Walter Roberson
2012 年 2 月 13 日
v = 200;
theta = 20;
g = 32.2;
i = 0;
t(1) = 0;
h(1) = 0;
x(1) = 0;
while(h(end) >= 0)
i=i+1;
h(i+1) = v.*(t(i)).*sind(theta)-1/2.*g.*(t(i)).^2;
x(i+1) = v.*(t(i)).*cosd(theta);
t(i+1) = t + 0.1;
end
2 件のコメント
Benjamin Lynch
2012 年 2 月 13 日
Srinivas
2012 年 2 月 13 日
change this line
t(i+1) = t(i) + 0.1;
カテゴリ
ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!