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

采纳的回答

Alan Stevens
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 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by