How To Write ODE45 Function File?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Matthew
am 21 Sep. 2017
Beantwortet: Walter Roberson
am 21 Sep. 2017
I have the following code in a script file.
tspan = [0 12];
v0 = 0;
[t,v] = ode45(@(t,v) 9.81-(0.25/68.1)*v^2, tspan, v0);
How can I break this apart so it is in the form of a function with a parent file and a child file? I'm new to functions, so although the answer is probably simple, it's not obvious to me.
Thanks in advance, M Ridzon
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 21 Sep. 2017
tspan = [0 12];
v0 = 0;
[t,v] = ode45(@myode, tspan, v0);
function dv = myode(t, v)
dv = 9.81-(0.25/68.1)*v.^2;
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!