Help in implementing ode45 in app designer

조회 수: 3 (최근 30일)
9times6
9times6 2020년 3월 8일
댓글: J. Alex Lee 2020년 3월 9일
methods (Static)
function dydt = odefun(app,t3,Y,A)
dydt = 0;
dydt = A+2*t3;
end
end
properties (Access = public)
t = 0:0.005:20;
initial_x=2;
A=0;
t1=0; x=0;
end
methods (Access = private)
% Button pushed function: Button
function ButtonPushed(app, event)
[app.t1,app.x] = ode45(@(t,Y) app.odefun(t,Y,app.A), app.t, app.initial_x);
plot(app.UIAxes,app.t1,app.x,'-o');
end
end
This is my sample code. If I save the same function (odefun) as a separate file in the current directory, this code works. However, if I include the same function as methods (Static), I get the following error: 'Not enough input arguments...'. I remember, I read somewhere, that the parameters need to be initialized, which I have done. Still the code does not work. Any help in this regard will be appreciated. Thank you!

답변 (1개)

J. Alex Lee
J. Alex Lee 2020년 3월 9일
Static methods don't assume that the app is passed as the first argument, so remove "app" from the arg list
methods (Static)
function dydt = odefun(t3,Y,A)
dydt = 0;
dydt = A+2*t3;
end
end
  댓글 수: 1
J. Alex Lee
J. Alex Lee 2020년 3월 9일
...i think...i just got swept with doubt.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by