?? sdoaspc_s.m
字號(hào):
function [sys,x0,str,ts] = sdoaspc_s(t,x,u,flag, method, restParam)%% The general form of an M-File S-function syntax is:% [SYS,X0,STR,TS] = SFUNC(T,X,U,FLAG,P1,...,Pn)%% Optional parameters, P1,...,Pn can be provided to the S-function and% used during any FLAG operation.%% Copyright (c) 1990-1998 by The MathWorks, Inc. All Rights Reserved.% $Revision: 1.3 $% The following outlines the general structure of an S-function.switch flag, case 0, [sys,x0,str,ts]=mdlInitializeSizes; case 1, sys=mdlDerivatives(t,x,u); case 2, sys=mdlUpdate(t,x,u); case 3, sys=mdlOutputs(t,x,u, method, restParam); case 4, sys=mdlGetTimeOfNextVarHit(t,x,u); case 9, sys=mdlTerminate(t,x,u); otherwise error(['Unhandled flag = ',num2str(flag)]);end% end sdoaspc_s%%=============================================================================% mdlInitializeSizes% Return the sizes, initial conditions, and sample times for the S-function.%=============================================================================%function [sys,x0,str,ts]=mdlInitializeSizes%% call simsizes for a sizes structure, fill it in and convert it to a% sizes array.%% Note that in this example, the values are hard coded. This is not a% recommended practice as the characteristics of the block are typically% defined by the S-function parameters.%sizes = simsizes;sizes.NumContStates = 0;sizes.NumDiscStates = 0;sizes.NumOutputs = 1;sizes.NumInputs =-1; % DYNAMICALLY SIZED INPUT PORT WIDTH sizes.DirFeedthrough = 1;sizes.NumSampleTimes = 1; % at least one sample time is neededsys = simsizes(sizes);% initialize the initial conditionsx0 = [];% str is always an empty matrixstr = [];% initialize the array of sample timests = [0 0];% end mdlInitializeSizes%%=============================================================================% mdlDerivatives% Return the derivatives for the continuous states.%=============================================================================%function sys=mdlDerivatives(t,x,u)sys = [];% end mdlDerivatives%%=============================================================================% mdlUpdate% Handle discrete state updates, sample time hits, and major time step% requirements.%=============================================================================%function sys=mdlUpdate(t,x,u)sys = [];% end mdlUpdate%%=============================================================================% mdlOutputs% Return the block outputs.%=============================================================================%function sys=mdlOutputs(t,x,u, method, restParam) if (length(u) == 2) restParam{4}=u(2); end; % Detection method estimated the number of sources (noSrc=u(2))... getinvar % Gets the input variable "inVar1" from the previous Simulink block. outVar1 = sdoaspc(method, inVar1, restParam{:}); % Calculate the DOA spectrum by a DBT function. putoutvarclear % Clear the variable "inVar1" and puts the output variable "outVar1" % to the next Simulink block.% end mdlOutputs%%=============================================================================% mdlGetTimeOfNextVarHit% Return the time of the next hit for this block. Note that the result is% absolute time. Note that this function is only used when you specify a% variable discrete-time sample time [-2 0] in the sample time array in% mdlInitializeSizes.%=============================================================================%function sys=mdlGetTimeOfNextVarHit(t,x,u)sampleTime = 1; % Example, set the next hit to be one second later.sys = t + sampleTime;% end mdlGetTimeOfNextVarHit%%=============================================================================% mdlTerminate% Perform any end of simulation tasks.%=============================================================================%function sys=mdlTerminate(t,x,u)sys = [];% end mdlTerminate
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -