Help in implementing ode45 in app designer

3 visualizzazioni (ultimi 30 giorni)
9times6
9times6 il 8 Mar 2020
Commentato: J. Alex Lee il 9 Mar 2020
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!

Risposte (1)

J. Alex Lee
J. Alex Lee il 9 Mar 2020
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

Categorie

Scopri di più su Programming in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by