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 Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by