一个数学建模题
一慢跑者沿着他喜欢的路线跑步,有只狗看见他了,就追他,求狗的路线。 不要到处都灌水啊,有了呀 <FONT color=#555555>%书上的一个程序,描述一只狗追一名慢跑者的运动轨迹 </FONT><P>global w;y0=; % initial conditions, starting point of the dog
w=10; % w speed of the dog
options=odeset('RelTol',1e-5,'Events','on');
=ode23('dog',,y0,options); <P>J=[];
for h=1:length(t)
w=jogger(t(h));
J=;
end <P>xmin=min(min(Y(:,1)),min(J(:,1)));
xmax=max(max(Y(:,1)),max(J(:,1)));
ymin=min(min(Y(:,2)),min(J(:,2)));
ymax=max(max(Y(:,2)),max(J(:,2))); <P>clf;
hold on
axis();
axis equal
title('The jogger and the Dog') <P>for h=1:length(t)-1
plot(,,'-',...
'color','r','EraseMode','none');
plot(,,':',...
'color','green','EraseMode','none');
drawnow
pause(0.1);
end
hold off <P>%%%%%%%%%%%%%% <P>function s=jogger(t) <P>s=; <P>%%%%%%%%%%%%%% <P>function =dog(t,z,flag); <P>global w% w=speed of the dog
X=jogger(t);
h=X-z;
nh=norm(h);
if nargin<3 | isempty(flag) % normal output
zs=(w/nh)*h;
else
switch(flag)
case 'events' % at norm(h)=0 there is a singularity
zs=nh-1e-3; % zero crossing at pos_dog=pos_jogger
isterminal=1;% this is a stopping event
direction=0; % don't care if decrease or increase
otherwise
error(['Unknown flag:' flag]);
end
end
<P>http://bbs.jzit.edu.cn/jzitbbs/usr/24/24_69_15.gif</P>
<P>
<TABLEheight=70 cellSpacing=0 cellPadding=0 width="100%">
<TR vAlign=top>
<TD ><FONT color=#333333>程序中用到ode23函数,解微分方程。 </FONT></TD></TR></TABLE></P> lap! 书上有 高中书上就有了,自己去看啊~~ <P>晕倒呀,,都有啦,,还在这说,,真是的,,不像话,,来个像样的呀,</P>
页:
[1]