资源简介
对二阶倒立摆利用滑膜变结构控制方法 进行摆角的控制
代码片段和文件信息
function [sysx0strts] = Identify_cyj(txuflag)
switch flag
%%%%%%%%%%%%%%%%%%
% Initialization %
%%%%%%%%%%%%%%%%%%
case 0
[sysx0strts]=mdlInitializeSizes;
%%%%%%%%%%%%%%%
% Derivatives %
%%%%%%%%%%%%%%%
case 1
sys=mdlDerivatives(txu);
%%%%%%%%%%
% Update %
%%%%%%%%%%
case 2
sys=mdlUpdate(txu);
%%%%%%%%%%%
% Outputs %
%%%%%%%%%%%
case 3
sys=mdlOutputs(txu);
%%%%%%%%%%%%%%%%%%%%%%%
% GetTimeOfNextVarHit %
%%%%%%%%%%%%%%%%%%%%%%%
case 4
sys=mdlGetTimeOfNextVarHit(txu);
%%%%%%%%%%%%%
% Terminate %
%%%%%%%%%%%%%
case 9
sys=mdlTerminate(txu);
%%%%%%%%%%%%%%%%%%%%
% Unexpected flags %
%%%%%%%%%%%%%%%%%%%%
otherwise
DAStudio.error(‘Simulink:blocks:unhandledFlag‘ num2str(flag));
end
% end sfuntmpl
%
%=============================================================================
% mdlInitializeSizes
% Return the sizes initial conditions and sample times for the S-function.
%=============================================================================
%
function [sysx0strts]=mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates = 0;
sizes.NumDiscStates = 0;
sizes.NumOutputs = 1;
sizes.NumInputs = 6;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 1; % at least one sample time is needed
sys = simsizes(sizes);
%
% initialize the initial conditions
%
x0 = [];
%
% str is always an empty matrix
%
str = [];
%
% initialize the array of sample times
%
ts = [0 0];
% Specify the block simStateComliance. The allowed values are:
% ‘UnknownSimState‘ < The default setting; warn and assume DefaultSimState
% ‘DefaultSimState‘ < Same sim state as a built-in block
% ‘HasNoSimState‘ < No sim state
% ‘DisallowSimState‘ < Error out when saving or restoring the model sim state
simStateCompliance = ‘UnknownSimState‘;
% end mdlInitializeSizes
%
%=============================================================================
% mdlDerivatives
% Return the derivatives for the continuous states.
%=============================================================================
%
function sys=mdlDerivatives(txu)
sys = [];
% end mdlDerivatives
%
%=============================================================================
% mdlUpdate
% Handle discrete state updates sample time hits and major time step
% requirements.
%=============================================================================
%
function sys=mdlUpdate(txu)
sys = [];
% end mdlUpdate
%=============================================================================
% mdlOutputs
% Return the block outputs.
%=============================================================================
%
function sys=mdlOutputs(txu)
U=u;
if U(2)>pi && U(2)<2*pi;
angle2 = 2*pi-U(2);
else
angle2 = U(2);
end
if U(3)>pi && U(3)<2*pi;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 20047 2011-04-06 20:39 Inverted pendulum into the second-order\cyj.mdl
文件 4064 2011-04-06 20:34 Inverted pendulum into the second-order\Identify_cyj.m
文件 1775 2011-04-06 14:27 Inverted pendulum into the second-order\LQR_cyj.m
文件 1680 2011-04-06 14:22 Inverted pendulum into the second-order\ob
文件 1776 2011-04-06 14:24 Inverted pendulum into the second-order\SMC_cyj.m
目录 0 2011-07-09 21:48 Inverted pendulum into the second-order
----------- --------- ---------- ----- ----
29342 6
- 上一篇:图片相似度识别
- 下一篇:排队论源码数学建模用到
评论
共有 条评论