Help in implementing ode45 in app designer
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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!
0 commentaires
Réponses (1)
J. Alex Lee
le 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
1 commentaire
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!