How can I write these functions to the press
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
3 commentaires
Réponses (1)
Ameer Hamza
le 26 Juin 2020
You can use ode45() to solve such a system of ODEs.
ic = [2; 4];
xspan = [0 1];
[x, Q] = ode45(@odeFun, xspan, ic);
y_sol = Q(:,1);
z_sol = Q(:,2);
plot(x, Q);
legend({'y', 'z'}, 'FontSize', 16);
function dQdx = odeFun(x, Q)
% Q(1) <=> y, Q(2) <=> z
y = Q(1);
z = Q(2);
dydx = -2*y + 4*exp(-x) + exp(-1000*z^2);
dzdx = -y*z^2/3;
dQdx = [dydx; dzdx];
end
0 commentaires
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!