function [sys,x0,str,ts]=model_zhengqifashengqi(t,x,u,flag)
switch flag,
case 0
[sys,x0,str,ts] = mdlInitializeSizes;
case 1
sys=mdlDerivatives(x,u);
case 3
sys = mdlOutputs(x,t,u);
case {2,4,9}
sys = []; % do nothing
otherwise
error(['Unhandled flag=',num2str(flag)]);
end
function [sys,x0,str,ts] = mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates = 4;
sizes.NumDiscStates = 0;
sizes.NumOutputs = 1;
sizes.NumInputs = 3;
sizes.DirFeedthrough = 0;
sizes.NumSampleTimes = 1;
sys = simsizes(sizes);
x0 = [0;0;0;0];
str = [];
ts = [-1 0];
function sys=mdlDerivatives(x,u)
G1=0.058;pi=3.14;
sys(1,1) = G1*(u(2)-u(3));
sys(2,1) = -(1/(f4(u)))*x(2)-(f2(u)/(f4(u)))*(u(2)-u(3));
sys(3,1) =-2*(1/(f5(u)))^2*x(3)+x(4)+f3(u)*u(2);
sys(4,1) =-((1/(f5(u)))^2+4*pi*(1/f6(u))^2)*x(3);
%-------------------------------------------
function sys = mdlOutputs(x,t,u)
sys = x(1)+x(2)+x(3);
function G2=f2(u)
if(u(1)<0.05)
G2=9.63;
else if(u(1)>0.05)&(u(1)<=0.15)
G2=9.63+((9.63-4.46)/(0.05-0.15))*(u(1)-0.05);
else if(u(1)>0.15)&(u(1)<=0.3)
G2=4.46+((4.46-1.83)/(0.15-0.3))*(u(1)-0.15);
else if(u(1)>0.3)&(u(1)<=0.5)
G2=1.83+((1.83-1.05)/(0.3-0.5))*(u(1)-0.3);
else if(u(1)>0.5)&(u(1)<=1)
G2=1.05+((1.05-0.47)/(0.5-1))*(u(1)-0.5);
else
G2=0.47;
end
end
end
end
end
function G3=f3(u)
%-------------------------------------------
if(u(1)<0.05)
G3=0.181;
else if(u(1)>0.05)&(u(1)<=0.15)
G3=0.181+((0.181-0.226)/(0.05-0.15))*(u(1)-0.05);
else if(u(1)>0.15)&(u(1)<=0.3)
G3=0.226+((0.226-0.31)/(0.15-0.3))*(u(1)-0.15);
else if(u(1)>0.3)&(u(1)<=0.5)
G3=0.31+((0.31-0.215)/(0.3-0.5))*(u(1)-0.3);
else if(u(1)>0.5)&(u(1)<=1)
G3=0.215+((0.215-0.105)/(0.5-1))*(u(1)-0.5);
else
G3=0.105;
end
end
end
end
end
function tao2=f4(u)
%-------------------------------------------
if(u(1)<0.05)
tao2=48.4;
else if(u(1)>0.05)&(u(1)<=0.15)
tao2=48.4+((48.4-21.5)/(0.05-0.15))*(u(1)-0.05);
else if(u(1)>0.15)&(u(1)<=0.3)
tao2=21.5+((21.5-4.5)/(0.15-0.3))*(u(1)-0.15);
else if(u(1)>0.3)&(u(1)<=0.5)
tao2=4.5+((4.5-3.6)/(0.3-0.5))*(u(1)-0.3);
else if(u(1)>0.5)&(u(1)<=1)
tao2=3.6+((3.6-3.4)/(0.5-1))*(u(1)-0.5);
else
tao2=3.4;
end
end
end
end
end
function tao1=f5(u)
%-------------------------------------------
if(u(1)<0.05)
tao1=41.9;
else if(u(1)>0.05)&(u(1)<=0.15)
tao1=41.9+((41.9-26.3)/(0.05-0.15))*(u(1)-0.05);
else if(u(1)>0.15)&(u(1)<=0.3)
tao1=26.3+((26.3-43.4)/(0.15-0.3))*(u(1)-0.15);
else if(u(1)>0.3)&(u(1)<=0.5)
tao1=43.4+((43.4-34.8)/(0.3-0.5))*(u(1)-0.3);
else if(u(1)>0.5)&(u(1)<=1)
tao1=34.8+((34.8-28.6)/(0.5-1))*(u(1)-0.5);
else
tao1=28.6;
end
end
end
end
end
function T=f6(u)
%-------------------------------------------
if(u(1)<0.05)
T=119.6;
else if(u(1)>0.05)&(u(1)<=0.15)
T=119.6+((119.6-60.5)/(0.05-0.15))*(u(1)-0.05);
else if(u(1)>0.15)&(u(1)<=0.3)
T=60.5+((60.5-17.7)/(0.15-0.3))*(u(1)-0.15);
else if(u(1)>0.3)&(u(1)<=0.5)
T=17.7+((17.7-14.2)/(0.3-0.5))*(u(1)-0.3);
else if(u(1)>0.5)&(u(1)<=1)
T=14.2+((14.2-11.7)/(0.5-1))*(u(1)-0.5);
else
T=11.7;
end
end
end
end
end