Solving Numerical Differential Equation
古いコメントを表示
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);
回答 (1 件)
Walter Roberson
2019 年 12 月 12 日
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
カテゴリ
ヘルプ センター および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!