Solving Numerical Differential Equation
Afficher commentaires plus anciens
I've tried several different ways to write this with an anonymous function, but I keep getting the same error. I'm not sure if I am missing a small detail or a larger concept as I don't really understand what the error means exactly.
l_d=1.225;
c=1.75;
A=1;
m=10;
g=9.8;
v0=v(0)==0;
dvdt=(m*g-.5*l_d*A*c*(v(t))^2)/m
functanon=@(t,v) dvdt
[ts,vs]=ode45(@(t,v)functanon,[0 4],v0)
Gives the error:
Inputs must be floats, namely single or double.
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Réponses (1)
Walter Roberson
le 12 Déc 2019
Use
v0 = 0;
you tried to use an equation as an intial condition, but that can be done only for symbolic differential equations.
dvdt=(m*g-.5*l_d*A*c*(v(t))^2)/m
functanon=@(t,v) dvdt
[ts,vs]=ode45(@(t,v)functanon,[0 4],v0)
should be
dvdt = @(t, v) (m*g-.5*l_d*A*c*(v)^2)/m;
[ts,vs]=ode45(dvdt,[0 4],v0)
But first you have to define l_d
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!