Help with ODE45
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Sydney Brown
am 25 Mär. 2020
Bearbeitet: James Tursa
am 26 Mär. 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 Kommentare
Akzeptierte Antwort
James Tursa
am 25 Mär. 2020
Bearbeitet: James Tursa
am 26 Mär. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!