Not enough input argument for GUI

3 visualizzazioni (ultimi 30 giorni)
Sofea Irene
Sofea Irene il 2 Mar 2023
Commentato: Sofea Irene il 5 Mar 2023
Hi everyone. I am a student, I have a project which need me to create a GUI with 4 differents functions and 4 differents data. I already tried by using 2 different functions and I can run the GUI. but when I tried to run the GUI with 4 different functions I keep on getting the error,
Not enough input arguments.
Error in Covid_model_App/f (line 59)
Error in Covid_model_App>@(varargin)app.f(varargin{:}) (line 396)
[tsol,xsol] = ode45(@app.f,tspan,x0);
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 106)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in Covid_model_App/start_sg_Callback (line 396)
[tsol,xsol] = ode45(@app.f,tspan,x0);
Error while evaluating Button PrivateButtonPushedFcn.
Is there anyone can help me? What is means by 'not eneough input arguments'? Thank you in advance for your help.
  2 Commenti
Sofea Irene
Sofea Irene il 4 Mar 2023
Hi, I already upload the files below.. thank you for your guidance.

Accedi per commentare.

Risposta accettata

Jan il 2 Mar 2023
"Not enough input arguments" mean, that you call a function with less input arguments that needed.
This line;
[tsol,xsol] = ode45(@app.f,tspan,x0);
let ODE45 call app.f with 2 inputs t and x. You try to access handles in the code, which might be a 3rd input (Please post the ocde to clarify this. It is always hard to fix code which cannot be seen.).
It is a bad design to store the function to be integrated as function handle inside the GUI. Keep code for calculations and GUI separated. Move the contents of app.f to a separate function and provide the contents of handles.user_eovump as parameter:
% in Covid_model_App/start_sg_Callback (line 396)
b = str2double(get(handles.user_eovump,'String')) / 100;
[tsol, xsol] = ode45(@(t, x) yourFcn(t, y, b, tspan, x0);
function dx = yourFcn(t, x, b)
... your function to be integrated
By this way, the function can be integrated independently from the GUI also, e.g. in a bacth job or loop.
  4 Commenti
Sofea Irene
Sofea Irene il 5 Mar 2023
@Jan!! Thank you very much for your help and guidance. I follow all your steps and I manage tu run my coding without any error. Again, thank you for helping me. I appreciate your help. Have a great day!

Accedi per commentare.

Più risposte (0)


Scopri di più su Numerical Integration and Differential Equations 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