Help with ODE45
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Sydney Brown
le 25 Mar 2020
Modifié(e) : James Tursa
le 26 Mar 2020
So I need to solve the second order differential function y''-y=G(t) where G(t) is the two functions seen below. I attempted to try to use ode45 to solve the first, but it didn't work. I also need to plot these two solutions together.
syms k t
G1 = symsum(t-2*k*pi,k,0,3);
G2 = symsum(2*pi-t+2*k*pi,k,3,5);
[tsol1,xsol1] = ode45(@(t,x) [x(2);G1-x(1)], [0,3],[0; 1]);
0 commentaires
Réponse acceptée
James Tursa
le 25 Mar 2020
Modifié(e) : James Tursa
le 26 Mar 2020
G1 and G2 are symbolic expressions. ode45( ) is a numeric solver. You will need to turn G1 and G2 into actual non-symbolic code in order to use them with ode45( ). I.e., non-symbolic functions or expressions involving t. E.g., could create a function handle for this:
>> F1 = str2func(['@(t)' char(G1)])
F1 =
@(t)4*t-12*pi
>> [tsol1,xsol1] = ode45(@(t,x) [x(2);F1(t)-x(1)], [0,3],[0; 1]);
0 commentaires
Plus de réponses (0)
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!