フィルターのクリア

How to save the iteration at every time step in this code?

2 ビュー (過去 30 日間)
Robert101
Robert101 2019 年 12 月 27 日
コメント済み: Robert101 2019 年 12 月 28 日
K1 = 3.4;
D1 = 1;
D2 = 3.5;
R1 = 5.0;
p1 = 4.0;
C1 = 1.0;
C2 = 1.0;
dt = 0.1;
E1 = 1.0;
Y1 = 1.0;
for i=1:1000000
C1(i) = C1(i) + dt*(E1*K1 - R1*C1(i)*Ci - Y1*D1*C1(i)*p1);
end

採用された回答

Cris LaPierre
Cris LaPierre 2019 年 12 月 28 日
Your code is already set up to capture a value at every iteration
C1(i)=...
There is, however, a logic flaw that I see. The equation indexes the next row of C1 before there is a value there. Perhaps try something like this?
for i=1:1000000
C1(i+1) = C1(i) + dt*(E1*K1 - R1*C1(i)*Ci - Y1*D1*C1(i)*p1);
end
  1 件のコメント
Robert101
Robert101 2019 年 12 月 28 日
Thanks a lot. Its working now. I am glad for your explanation. It is very clear and to the point.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePhysics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by