Help with a loop that computes at each step
古いコメントを表示
hi im doing an assignmenr where i have 5 different stepsizes that compose a row vector hs. i have 100/hs steps for which id like to compute the value th2 at each stepsize.
th1=1;
th2=1;
w1=0;
w2=0;
hs(1)=[0.05];
hs(2)=[0.05/2];
hs(3)=[0.05/4];
hs(4)=[0.05/8];
hs(5)=[1/1000];
th2s=[];
????????????
for i=1:N
k1= h*fpend(y);
k2=h*fpend(y + k1/2);
k3=h*fpend(y + k2/2);
k4= h*fpend(y + k3);
y = y + (k1 + 2*k2 + 2*k3 + k4) / 6;
end
th2s=[th2s,y(2)]
6 件のコメント
Awais Saeed
2021 年 11 月 13 日
Your question is not clear. Be specific. Why do you have a 2nd end at the end?
Lavorizia Vaughn
2021 年 11 月 13 日
Awais Saeed
2021 年 11 月 13 日
You still did not made the question clear. what is h and y and ?????????????
Lavorizia Vaughn
2021 年 11 月 13 日
Lavorizia Vaughn
2021 年 11 月 13 日
Jan
2021 年 11 月 13 日
The instruction is nonsense: For k=1, the value of h = 0.05/2(k-1) is Inf.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!