function [sys,x0,str,ts] = sfuntmpl(t,x,u,flag)
switch flag,
%%%%%%%%%%%%%%%%%%
% Initialization %
%%%%%%%%%%%%%%%%%%
case 0,
[sys,x0,str,ts]=mdlInitializeSizes;
%%%%%%%%%%%%%%%
% Derivatives %
%%%%%%%%%%%%%%%
case 1,
sys=mdlDerivatives(t,x,u);
%%%%%%%%%%
% Update %
%%%%%%%%%%
case 2,
sys=mdlUpdate(t,x,u);
%%%%%%%%%%%
% Outputs %
%%%%%%%%%%%
case 3,
sys=mdlOutputs(t,x,u);
%%%%%%%%%%%%%%%%%%%%%%%
% GetTimeOfNextVarHit %
%%%%%%%%%%%%%%%%%%%%%%%
case 4,
sys=mdlGetTimeOfNextVarHit(t,x,u);
%%%%%%%%%%%%%
% Terminate %
%%%%%%%%%%%%%
case 9,
sys=mdlTerminate(t,x,u);
%%%%%%%%%%%%%%%%%%%%
% Unexpected flags %
%%%%%%%%%%%%%%%%%%%%
otherwise
error(['Unhandled flag = ',num2str(flag)]);
end
% end sfuntmpl
%
%==================================================
% mdlInitializeSizes
% Return the sizes, initial conditions,
% and sample times for the S-function.
%==================================================
%
function [sys,x0,str,ts]=mdlInitializeSizes
sizes = simsizes;
% 该语句返回一个没有经过初始化的sizes数组,此数组是
% s-function信息的载体。
% 根据s-function的实际情况及sizes数组各个字段的意义可以
% 对各字段进行赋值。
sizes.NumContStates = 0;
sizes.NumDiscStates = 0;
sizes.NumOutputs = 0;
sizes.NumInputs = 0;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 1;
% at least one sample time is needed
sys = simsizes(sizes);
% 对sizes赋值完之后,再调用simsizes指令,将定义好的sizes
% 数组作为参数,并把结果返回给sys变量。
% 其实,simsizes(sizes)只是把sizes数组组成一个长度为6的
% 向量,因此完全可以用一条简单的赋值语句代替上述赋值。
% sys=[0,0,0,0,1,1];
% 注意输入的顺序与上述字段顺序相同。
% initialize the initial conditions
%
x0 = [];
%
% str is always an empty matrix
%
str = [];
%
% initialize the array of sample times
%
ts = [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)
sys = [];
% 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
没有合适的资源?快使用搜索试试~ 我知道了~
历史上见过的最好的Matlab(ppt课件)
共118个文件
m:79个
mdl:30个
ppt:5个
需积分: 9 28 下载量 118 浏览量
2009-04-18
08:51:16
上传
评论
收藏 478KB RAR 举报
温馨提示
历史上见过的最好最全的MATLAB课件,初学者可以由浅入深,层层逼近MATLAB编程的巅峰
资源推荐
资源详情
资源评论
收起资源包目录
历史上见过的最好的Matlab(ppt课件) (118个子文件)
sfuntmpl.m 3KB
vsfunc.m 3KB
mixedm.m 3KB
dsfunc.m 2KB
csfunc.m 2KB
exp1_3.m 2KB
callcheck.m 1KB
mean.m 1KB
exp4_10.m 892B
rect.m 875B
myhilb1.m 726B
stepchar.m 705B
exp4_23.m 686B
exp4_10_.m 664B
exp4_1.m 654B
exp4_9_.m 643B
exp4_2.m 638B
filt.m 638B
exp4_22.m 618B
exp4_16.m 604B
exp4_11.m 585B
exp2_6.m 578B
exp2_8.m 536B
exp4_9.m 536B
exp2_5_.m 536B
exp2_16.m 520B
exp4_15.m 504B
exp3_1.m 489B
exp2_3_.m 487B
exp3_2.m 481B
exp4_13.m 475B
exp4_12.m 451B
exp2_7.m 437B
rload.m 423B
exp2_9.m 414B
exp3_3.m 414B
elecsys.m 409B
myhilb.m 404B
exp4_17.m 395B
exp4_7.m 388B
exp4_3.m 382B
exp4_19.m 375B
exp4_8.m 346B
exp4_24.m 337B
exp1_2.m 330B
exp3_4.m 329B
exp4_11_.m 316B
exp1_1.m 309B
exp4_3_.m 293B
exp4_20.m 277B
exp4_12_.m 276B
exp4_10__.m 266B
exp2_17.m 265B
exp2_2.m 264B
exp2_4_.m 262B
exp4_5.m 259B
exp2_10.m 258B
exp4_4.m 257B
exp4_14_.m 255B
exp2_15.m 250B
exp2_4.m 245B
exp4_6_.m 229B
exp2_13_.m 217B
exp4_14.m 205B
exp4_21.m 203B
exp2_14.m 201B
exp2_1.m 193B
exp4_6.m 191B
exp4_18.m 182B
exp2_5.m 176B
exp2_3.m 148B
exp2_13.m 146B
prods.m 141B
sumhe.m 94B
exmdl2_1.m 70B
exp2_12.m 59B
exp2_11.m 47B
ploty.m 44B
initial.m 28B
s.mat 117KB
gui1.mat 46KB
y.mat 31KB
data.mat 952B
RS.mdl 17KB
inverter.mdl 13KB
dianlu.mdl 9KB
shiyufx.mdl 9KB
exm5_6.mdl 9KB
exp5_10.mdl 9KB
exm5_5.mdl 8KB
exp5_4.mdl 8KB
exm5_4.mdl 8KB
exp5_8.mdl 8KB
exp5_9.mdl 8KB
exp5_3.mdl 8KB
exm5_1.mdl 8KB
exp5_2.mdl 8KB
exp5_5.mdl 8KB
exp5_7.mdl 8KB
exm5_3.mdl 8KB
共 118 条
- 1
- 2
资源评论
zh1bo5
- 粉丝: 0
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功