Event-based ODE inside a handle class
    3 ビュー (過去 30 日間)
  
       古いコメントを表示
    
Greetings. I'm trying to find a way to use event-based ode insidea class as the code below:
The equation is more omplex and I'm using this instance for simplicity, the error I get is the same
classdef ODEevent < handle
    properties
        tstart = 0;
        tend = 5;
    end
    methods
        function odeObj = ODEevent()
            % Instance of the class
        end
        function [value, isterminal, direction] = odeEvent(this, x)
            x_des = x;
            value = x_des - 1;
            isterminal = 1;
            direction = 0;
        end
        function solveODE(this)
            tspan = [this.tstart this.tend];
            x0 = 0;
            odeOpts = odeset('Events', @this.odeEvent);
            [t, x] = ode45(@(t,x) 2*t, tspan, x0, odeOpts);
        end
    end
end
The error I'm getting is:
Error using ODEevent/odeEvent
Too many input arguments.
Error in ODEevent>@(varargin)this.odeEvent(varargin{:}) (line 22)
            odeOpts = odeset('Events', @this.odeEvent);
Error in odeevents (line 28)
  eventValue = feval(eventFcn,t0,y0,eventArgs{:});
Error in ode45 (line 148)
  odeevents(FcnHandlesUsed,odeFcn,t0,y0,options,varargin);
Error in ODEevent/solveODE (line 23)
            [t, x] = ode45(@(t,x) 2*t, tspan, x0, odeOpts);
Thanks in advane
Regards
0 件のコメント
採用された回答
  Walter Roberson
      
      
 2020 年 9 月 18 日
        You need a static method. ode event functions are not expecting the object to be passed. They are, however, expecting t to be passed as the first parameter.
その他の回答 (0 件)
参考
カテゴリ
				Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!