フィルターのクリア

S-function to initialize

2 ビュー (過去 30 日間)
cyberdyne
cyberdyne 2011 年 9 月 10 日
This is the s-function that animates a robotic manipulator model; it does't see the vector to initialize the robot graphic (in the function is [0 pi/2 0 0 pi/2 -pi/2 pi]), but it considers only [0 0 0 0 0 0 0].
function [sys,x0,str,ts] = splotbot(t,x,u,flag, robot)
switch flag,
case 0
% initialize the robot graphics
[sys,x0,str,ts] = mdlInitializeSizes; % Init
plot(robot, [0 pi/2 0 0 pi/2 -pi/2 pi]);
case 2
% come here on update
if ~isempty(u),
plot(robot, u');
drawnow
end
ret = [];
case {1, 4, 9}
ret = [];
end
%
%=============================================================================
% 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 = 0;
sizes.NumInputs = -1;
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];
% end mdlInitializeSizes
  1 件のコメント
Fangjun Jiang
Fangjun Jiang 2011 年 9 月 10 日
What is your question?

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by