Struggling with ode45 MATLAB function
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Felix Lauwaert
il 7 Ago 2015
Risposto: Walter Roberson
il 7 Ago 2015
Hello everybody,
I'm trying to introduce my function into ode45 to solve it but it messages me "Not enough input arguments". I allready know how to folve the problem the ugly way, but it's not my will to have an ugly function because it's part of a larger group of functions working together. I'll explain it with an example:
fun= @(t,x) = [ x(3) , x(4) , x(1)*sin(x4-u) , x(1)/(x(2)-u)*cos(x5-u) ]
As you see, I have a function with 4 ODEs so I only have to give ode45 4 initial conditions for x(1) to x(4). BUT I have a constant 'u' inside fun and I don't want to define fun in the function where I call ode45 because I'll have to use different 'u' values in my group of functions. If it's possible, I don't want to use global variables.
Thanks for your help.
0 Commenti
Risposta accettata
Walter Roberson
il 7 Ago 2015
fun= @(t,x, u) = [ x(3) , x(4) , x(1)*sin(x4-u) , x(1)/(x(2)-u)*cos(x5-u) ]
then when you need to specialize for a particular u,
funu = @(t,x) fun(t,x,specific_u)
and then pass funu into ode45
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Ordinary Differential Equations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!