Solving two dependent two variable ordinary differential equation

18 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Alan Stevens
Alan Stevens el 15 de Sept. de 2020
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

Más respuestas (0)

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by