1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| function [sys,x0,str,ts] = atmosphere_sfction(t,x,u,flag)
switch flag,
case 0
sys=mdlInitializeSizes;
case 3
gamma=1.4;
r=287.0529;
ro_alt_0=1.225;
if (0<=u)&&(u<=11000);
Ps=101325*((1-(22.5576934*(10^-6))*u)^5.2558774);
T=288.150-0.0065*u;
a=sqrt(gamma*r*T);
ro=(Ps/(r*T));
d=ro/ro_u_0;
sys=[Ps T a ro d];
elseif (11000<u)&&(u<=20000);
Ps=22632*exp((-157.688446*(10^-6))*(u-11000));
T=216.65;
a=sqrt(gamma*r*T);
ro=(Ps/(r*T));
d=ro/ro_u_0;
sys=[Ps T a ro d];
elseif (20000<u)&&(u<=32000);
Ps=5474.9*((1+(4.6157398*(10^-6))*(u-20000))^-34.1632061);
T=216.65+0.001*(u-20000);
a=sqrt(gamma*r*T);
ro=(Ps/(r*T));
d=ro/ro_u_0;
sys=[Ps T a ro d];
elseif (32000<u)&&(u<=47000);
Ps=868.014*((1+(12.2457904*(10^-6))*(u-32000))^-12.2011445);
T=228.65+0.0028*(u-32000);
a=sqrt(gamma*r*T);
ro=(Ps/(r*T));
d=ro/ro_u_0;
sys=[Ps T a ro d];
end
case { 1, 2, 4, 9 }
sys=[];
otherwise
error(['Unhandled flag = ',num2str(flag)]);
end
function sys = mdlInitializeSizes()
sizes = simsizes;
sizes.NumContStates = 0;
sizes.NumDiscStates = 0;
sizes.NumOutputs = 1;
sizes.NumInputs = 1;
sizes.DirFeedthrough = 0;
sizes.NumSampleTimes = 0;
str=[];
x0 = [];
sys=simsizes(sizes); |
Partager