www.pudn.com > AUV-tarcking.zip > X.m, change:2012-04-25,size:804b


function [sys,x0,str,ts] = s_function(t,x,u,flag) 
 
switch flag, 
  case 0, 
    [sys,x0,str,ts]=mdlInitializeSizes; 
  case 1, 
    sys=mdlDerivatives(t,x,u); 
 
  case 3, 
    sys=mdlOutputs(t,x,u); 
 
  case {2,4,9} 
    sys=[]; 
     
  otherwise 
    error(['Unhandled flag = ',num2str(flag)]); 
 
end 
 
function [sys,x0,str,ts]=mdlInitializeSizes 
 
sizes = simsizes; 
 
sizes.NumContStates  = 1; 
sizes.NumDiscStates  = 0; 
sizes.NumOutputs     = 1; 
sizes.NumInputs      = 4; 
sizes.DirFeedthrough = 0; 
sizes.NumSampleTimes = 1;    
 
sys = simsizes(sizes); 
 
x0  = [0]; 
str = []; 
ts  = [0 0]; 
 
function sys=mdlDerivatives(t,x,u) 
U=u(1); 
V=u(2); 
R=u(3); 
fi=u(4); 
sys=U*cos(fi)-V*sin(fi); 
function sys=mdlOutputs(t,x,u) 
sys=x;