hello,can you help me to solve this error returns a vector of length 2, but the length of initial conditions vector is 4.

1 次查看(过去 30 天)
function xdot = blood_glucosee1(t,x)
global u A
% Input (1)
% Plasma Glucose Conc. (mg/dl)
X1 = x(1,1);
% Plasma Insulin Conc. (mU/L) in remote compartment
X2 = x(2,1);
% Plasma Insulin Conc. (mU/L)
X3= x(3,1);
X4=x(4,1);
% Disturbances (1):
K=50;
% Disturbance from the large meal
A=50;
B=0.025;
D = A * exp(-B * t);
% Parameters
% Basal values of glucose and insulin conc.
G_basal = 75; % mmol/L
X_basal = 15; % mU/L
I_basal = 15; % mU/L
% For a type-1 diabetic
%P1 =0.0317; %0.028735; % min-1
P2 = 0.0123;%0.028344; % min-1
P3 = 8.2*10^-8; % mU/L
%V1 = 12; % L
n = 0.2659; % min
%th=6*10^-5;
%h=79;
y1=0.001;
y2=0.02;
q=0.01;
dotD=diff(D);
D2dot=diff(dotD);
X1dot = -X2*X1+ D;
e= X1-G_basal;
edot= X1dot;
f1=-X1*X2^2+D*X2+P2*X1*X2+P3*I_basal*X1+dotD;
e2dot=f1-P3*X1*X3;
f2=-X1*X2^3+D*X2^2-2*P3*X1*X2*X3-3*P3*I_basal*X1*X2-3*P2*X1*X2^2+X2*dotD+P3*X3*D+P2*P3*X1*X3-P2*P3*I_basal*X1-P2^2*X1*X2+D2dot+P3*X3*D+P3*n*(X3-I_basal)*X2;
g=-P3*X1;
s=e2dot+y1*edot+y2*e;
X2dot =( -P2*X2)+ P3 * (X3 - I_basal);
F=f2+(y1*f1)-(y1*P3*X3*X1)+(y2*X2*X1)+(y2*D);
U=(-F/g)-K*sign(s)-q*s/g;
e3dot=f2+g*U;
X3dot = -n *(X3-I_basal)+U;
% Vector to return
xdot = [X1dot; X2dot ;U ; X3dot];
  2 个评论
Rik
Rik 2020-6-12
This time I edited your question for you. Next time, please use the tools explained on this page to make your question more readable.
Also, why are you using global variable?
There are several warnings from mlint. You should either solve the issue, or tell Matlab that you know and it's actually fine by using the ok pragma (left click on the orange line and select one of the options from the 'Suppress' submenu).
What inputs give rise to your error?
senadjki mohamed islam
first i used a solver to solve the diffrentiels eq then i wanted to use sliding mode to controle the sys
the input error is U
for global variable its just a mistake from the first programe
thanks

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

产品


版本

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by