Solving two dependent two variable ordinary differential equation
3 次查看(过去 30 天)
显示 更早的评论
I have to solve this system of ODE
dy1/dt = (y2-y1)/6.579
y2/dt = [-(y2-y1)/6.579] + 2.115*[ 40 - 4y2]
Here, i have the initial values as y1in = 0, y2in = 0
Also how can i plot y2 and y1 against time? im new to matlab,please help
0 个评论
采纳的回答
Alan Stevens
2020-9-15
Here's the basic syntax. Look up ode45 in the documentation for more detail.
tspan = [0 2];
y0 = [0, 0];
[t, y] = ode45(@rates,tspan,y0);
plot(t,y(:,1),t,y(:,2))
function dydt = rates(~,y)
dydt = [(y(2)-y(1))/6.579;
-(y(2)-y(1))/6.579+2.115.*(40 - 4*y(2))];
end
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!