Hello, everyone,
I'm working on a code for a GUI in Matlab where I use a subfunction that uses ode45, the problem is that it sends me this error:
Error using Prueba_con_Bergman>f (line 292)
Not enough input arguments.
Error in odearguments (line 87)
f0 = feval(ode,t0,y0,args{:});
args{1} to yp0.
Error in ode45 (line 113)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0,
f0, odeArgs, odeFcn, ...
Error in Prueba_con_Bergman>pushbutton1_Callback
(line 264)
[t,x] = ode45(@f,tspan,x0);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in Prueba_con_Bergman (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)Prueba_con_Bergman('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
I'm saving the numbers given to the GUI into some variables, where it is also converted into double. This is the part that executes the ode 45:
function pushbutton1_Callback(hObject, eventdata, handles)
tf= str2double(get(handles.edit6,'String'))
G0= str2double(get(handles.edit7,'String'))
X0= str2double(get(handles.edit8,'String'))
I0= str2double(get(handles.edit10,'String'))
tspan = [0; tf];
x0 = [G0; X0; I0];
[t,x] = ode45(@f,tspan,x0);
axes(handles.axes2);
plot(t,x(:,1));
grid on
axes(handles.axes3);
plot(t,x(:,2));
grid on
axes(handles.axes4);
plot(t,x(:,3));
grid on
function dxdt = f(t,x,handles)
p1= str2double(get(handles.edit1,'String'))
p2= str2double(get(handles.edit2,'String'))
p3= str2double(get(handles.edit3,'String'))
n= str2double(get(handles.edit4,'String'))
Gb= str2double(get(handles.edit11,'String'))
dxdt = [ (p1 - x(2))*x(1) - ((p1)*Gb);
(p2*x(2) + p3*x(3));
(n*x(3))
];
I have no problem with the first variables, it's just until line 292 that starts the problem, I tried it with constants instead of variables and it works. What it wrong with the code?
Thanks