differential equations - Calculate ODE's with MATLAB -
the differential equations:
α'(t)=s(β-βα+α-qα^2)
β'(t)=(s^-1)(-β-αβ+γ)
γ'(t)=w(α-γ)
intitial values
α (0) = 30.00
β (0) = 1.000
γ (0) = 30.00
calculation
i want solve problem t_0=0 t=10 while using values s = 1, q = 1 , w = 0.1610
i've no idea how write function ode's , appreciate help!
i'm not in habit of solving other people's homework, today's lucky day guess.
so, have system of coupled ordinary differential equations:
α'(t) = s(β-α(β+1)-qα²)
β'(t) = (-β-αβ+γ)/s
γ'(t) = w(α-γ)
and want solve for
y = [α(t) β(t) γ(t)]
with 0 < t < 10, s = 1, q = 1, w = 0.1610. way in matlab define function computes derivative ([α'(t) β'(t) γ'(t)]), , throw in 1 of ode solvers (ode45
first bet):
s = 1; q = 1; w = 0.1610; % define y(t) = [α(t) β(t) γ(t)] = [y(1) y(2) y(3)]: deriv = @(t,y) [... s * (y(2) - y(1)*(y(2)+1) - q*y(1)^2) % α'(t) (-y(2) - y(1)*y(2) + y(3))/s % β'(t) w * (y(1)-y(3)) % γ'(t) ]; % initial value y0 = [30 1 10]; % time span integrate on tspan = [0 10]; % solve ode numerically [t, y] = ode45(deriv, tspan, y0)
this output
y = 30.0000 1.0000 10.0000 28.5635 0.9689 10.0049 % numerical solutions @ times t 27.2558 0.9413 10.0094 26.0603 0.9166 10.0136 ... ... ... = α(t) = β(t) = γ(t) t = 0 0.0016 0.0031 % corresponding times 0.0047 ...
you can plot so:
figure, clf, hold on plot(t, y(:,1), 'r') plot(t, y(:,2), 'g') plot(t, y(:,3), 'b') legend('\alpha(t)', '\beta(t)', '\gamma(t)')
which results in figure:
Comments
Post a Comment