ode45 Event Option

2 ビュー (過去 30 日間)
Duncan McIntosh
Duncan McIntosh 2016 年 12 月 11 日
コメント済み: Duncan McIntosh 2016 年 12 月 11 日
I am starting a parachute drop at 15000 ft and trying to stop at 5000 ft using the event option. The code works without the event when I call "solution_module" from the command window. With the event option, I get the following error message. SWITCH expression must be a scalar or character vector constant. Error in odeevents (line 31) switch lower(eventFcn) Error in ode45 (line 148) odeevents(FcnHandlesUsed,odeFcn,t0,y0,options,varargin); Error in solution_module (line 13) [T1,Y1,te,ye,ie]=ode45('ssm_module',[5:1:450],[V;A],options)

回答 (1 件)

Mischa Kim
Mischa Kim 2016 年 12 月 11 日
Duncan, I put the entire code into one file and slightly changed the code (ode calls), see attachment. Works for me.
One more thing, the way you coded the events function the integrator will stop at x = -5000.
Change to
lookfor = x(1) - 5000;
  1 件のコメント
Duncan McIntosh
Duncan McIntosh 2016 年 12 月 11 日
Works great. Thanks.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by