Solve ode in different interval
古いコメントを表示
Hi, I want to solve ode in different interval with different initial condition. Here is the code I have. I wonder if there is way to use while loop or for loop i can use to simplify the code?
st = 10;
n = 20;
c = 0.1;
x0 = 0.5;
p = [0.4, 1];
stoptime1 = linspace(0,st,n);
stoptime2 = linspace(st,2*st,n);
stoptime3 = linspace(2*st,3*st,n);
[t1,x1] = ode15s(@(t,x) 0.4*x*(1-x/k), stoptime1, x0);
[t2,x2] = ode15s(@(t,x) 0.4*x*(1-x/k), stoptime2, x1(end)*(1 - c));
[t3,x3] = ode15s(@(t,x) 0.4*x*(1-x/k), stoptime3, x2(end)*(1 - c));
x = [x1; x2; x3];
t = [t1; t2; t3];
plot(t, x)
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
