Solve a system of ODEs with a piecewise forcing function
이전 댓글 표시
I'm trying to solve a system of two ODEs with a piecewise forcing function. There are two cases, the first being instantaneous changes of the constant function. The second involves a linear decrease and increase. I haven't been able to make this work with the first case, and I'm hoping the solution works for the second as well. My code looks something like this:
funlev = [funlev1 0.5*funlev1 funlev1 0];
funp = mkpp([-12 0 48 72 180],funlev);
fun = ppval(funp,t);
fun2 = @(t,y) [A*fun-B*y(1);
B*y(1)+C-D*y(2)-E*fun*y(2)];
[t1,y1] = ode45(fun2,[-12 180],y0);
I'm thinking the issue is with the piecewise function, but I'm not positive. Am I missing something? If I'm not handling the piecewise function correctly, how would I do so?
답변 (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!