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!
