Error with ODE and nargin

1 view (last 30 days)
Divya Noonela
Divya Noonela on 18 Sep 2020
Commented: Divya Noonela on 23 Sep 2020
Hello, can anyone help me out with this.?
function xdot = glucoseff(t,x)
p1=0.028735;
p2=0.028344;
p3=5.0353e-5;
gb=200;
ib=0;
n=0.10;
vi=12;
a=0:0.1:10
ug=exp(-a);
g=x(1);
y=x(2);
i=x(3);
%
%odes
%
dgdt=(-p1*g)-(t*g)+(p1*gb)+ug;
dydt=(-p2*y)+(p3*i)-(p3*ib);
didt=(-n*i)+ui/vi;
xdot = [dgdt; dydt; didt];
end
clc;
x0=[200;0;10];
[t,x] = ode45('glucoseff',[0 10],0);
plot(x(:,1));
plot(x(:,2));
plot(x(:,3));
I don't understand the error :
Error using nargin
Error: File: glucoseff.m Line: 1 Column: 1
Function definitions are not permitted in this context.
Error in odearguments (line 60)
if (nargin(ode) == 2)
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in glucose_main (line 4)
[t,x] = ode45('glucoseff',[0 10],0);
  3 Comments
VBBV
VBBV on 19 Sep 2020
% if true
% code
%end
[t,x] = ode45(@glucoseff,[0 10],x0)
Divya Noonela
Divya Noonela on 23 Sep 2020
ug is a vector of same size of a

Sign in to comment.

Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!