figure('numbertitle','off','name','Matlab Animation
Demo--matlabfan','MenuBar','none')

prompt={'请输入速度v','请输入长度L','请输入半径r'};

default={'5','10','2'};
v=5;L=10;r=2;
p=inputdlg(prompt,'输入参数',1,default);
v=str2double(p(1));
L=str2double(p(2));
r=str2double(p(3));

if v=0L=0r=0
  warndlg('MATLABFAN提醒您：输入参数必须为整数','警告')
else
  axis([0,2r+L,0,2r])
  ox1=r;oy1=r;ox2=r+L;oy2=r;
  x1=r0.015vr+L;
  y1=2rones(size(x1));
  thita=00.015vrpi;
  x2=sin(thita)r+ox2;
  y2=cos(thita)r+oy2;
  x3=r+L-0.015vr;
  y3=zeros(size(x3));
  x4=-sin(thita)r+ox1;
  y4=-cos(thita)r+oy1;
  x=[x1 x2 x3 x4];
  y=[y1 y2 y3 y4];
  plot(x,y);
  text(0,-2,['长度L=' num2str(L) ' , ' '半径r=' num2str(r) ' , ' '速度v=' num2str(v)]);
  axis equal
  set(gca,'Visible','off')
  hm=line(r,2r,'color','red','marker','.','markersize',37,'erasemode','xor');
  while 1
      for i=1length(x)
          try
              set(hm,'xdata',x(i),'ydata',y(i));
              pause(0.0003)
              drawnow
          catch
              'www.xiexianbin.cn
              return
          end
      end
  end
end
