概述
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- function [sys,x0,str,ts] = sfunt(t,x,u,flag,b) %定义函数名称:sfunt switch flag, end % end sfuntmpl %============================================================================= % mdlInitializeSizes % Return the sizes, initial conditions, and sample times for the S-function. %============================================================================= function [sys,x0,str,ts]=mdlInitializeSizes %调用函数simsizes以创建结构体sizes sizes = simsizes; %用初始化信息填充结构体sizes sizes.NumContStates sizes.NumDiscStates sizes.NumOutputs sizes.NumInputs sizes.DirFeedthrough = 0; %不包含直接馈通(输出量中不含输入量) sizes.NumSampleTimes = 1; % (单个采样周期)at least on %根据上面的设置设定系统初始化参数 sys = simsizes(sizes); %给其他返回参数赋值 % initialize the initial conditions x0 % str is always an empty matrix str = []; %将str变量设置为空字符串 % initialize the array of sample times ts %初始化子程序结束 % end mdlInitializeSizes %============================================================================= % mdlDerivatives % Return the derivatives for the continuous states. %============================================================================= function sys=mdlDerivatives(t,x,u) % 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:当flag值为3时,计算输出量 % Return the block outputs. %============================================================================= function sys=mdlOutputs(t,x,u,b) if(x <= b) else end % end mdlOutputs %============================================================================= % mdlGetTimeOfNextVarHit % Return the time of the next hit for this block. % absolute time. % variable discrete-time sample time [-2 0] in the sample time array in % mdlInitializeSizes. %============================================================================= function sys=mdlGetTimeOfNextVarHit(t,x,u) sampleTime = 1; sys = t + sampleTime; % end mdlGetTimeOfNextVarHit %============================================================================= % mdlTerminate % Perform any end of simulation tasks. %============================================================================= function sys=mdlTerminate(t,x,u) sys = []; % end mdlTerminate
最后
以上就是受伤毛衣为你收集整理的matlab-simulink中s-function函数…的全部内容,希望文章能够帮你解决matlab-simulink中s-function函数…所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复