Numerical Differential Equation Matrix Form with Forcing Function
Afficher commentaires plus anciens
I'm trying to solve a fourth order differential equation with a forcing function t*e^(2t) with ODE45 in matrix form. The method below works fine:
F = @(t,y) [
y(2);
y(3);
y(4);
t*exp(2*t)+4*y(2)-3*y(3)+12*y(1)]
y0 = [0 0 0 -1/4]';
ode45(F, [0 4], y0);
But when I try a matrix form of the system, the forcing function returns an error for an undefined t.
A = [0 1 0 0
0 0 1 0
0 0 0 1
12 4 -3 0]
b = [0 0 0 -t*exp(2*t)]'
y0 = [0 0 0 -1/4]'
F = @(t, Y, A, b) A*Y+b;
ode45(@(t,Y) F, [0,4], y0)
I've used this method for undriven systems of first-order equations. Does anyone know how to modify the code to fix the error?
2 commentaires
Abraham Boayue
le 26 Mai 2018
It's a bit difficult to see what's going on when your original ode has been reduced to 4 systems of equations as seen in your code, especially in the form as a matrix. Could you post the original equations?
Timothy Sullivan
le 26 Mai 2018
Modifié(e) : Timothy Sullivan
le 26 Mai 2018
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!