声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1630|回复: 1

请教高手一个S函数(matlab内含)!!

[复制链接]
发表于 2006-11-30 23:06 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
谁能帮我注释一下这个S函数呢

function [sys,x0]=pndanim1(t,x,u,flag,ts);
%PNDANIM3 S-function for animating the motion of a pendulum.

%   Ned Gulley, 6-21-93
%   Copyright 1990-2002 The MathWorks, Inc.
%   $Revision: 5.10 $

global PendAnim1

if flag==2,
  if any(get(0,'Children')==PendAnim1),
    if strcmp(get(PendAnim1,'Name'),'simppend Animation'),
      set(0,'currentfigure',PendAnim1);
      hndlList=get(gca,'UserData');
      x=[u(1) u(1)+2*sin(u(2))];
      y=[0 -2*cos(u(2))];
      set(hndlList(1),'XData',x,'YData',y);
      set(hndlList(2),'XData',u(1),'YData',0);
      drawnow;
    end
  end
  sys=[];

elseif flag == 4 % Return next sample hit
  
  % ns stores the number of samples
  ns = t/ts;

  % This is the time of the next sample hit.
  sys = (1 + floor(ns + 1e-13*(1+ns)))*ts;

elseif flag==0,

  % Initialize the figure for use with this simulation
  animinit('simppend Animation');
  [flag,PendAnim1] = figflag('simppend Animation');
  axis([-3 3 -2 2]);
  hold on;

  x=[0 0];
  y=[0 -2];
  hndlList(1)=plot(x,y,'LineWidth',5,'EraseMode','background');
  hndlList(2)=plot(0,0,'.','MarkerSize',25,'EraseMode','back');
  set(gca,'DataAspectRatio',[1 1 1]);
  set(gca,'UserData',hndlList);

  sys=[0 0 0 2 0 0];
  x0=[];

end
回复
分享到:

使用道具 举报

 楼主| 发表于 2006-11-30 23:08 | 显示全部楼层

请教高手

:@Q我查看了一些书,上面说这是比较老的S函数格式,看了半天我也没有读懂~~~:@Q

[ 本帖最后由 pb0322 于  11:13 PM 编辑 ]
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-21 15:41 , Processed in 0.055050 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表