狼追兔子

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/04 01:04:13
狼追兔子狼追兔子狼追兔子在Matlab下输入:edit然后将下面两行百分号之间的内容,复制进去,保存%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%f

狼追兔子
狼追兔子

狼追兔子
在Matlab下输入:edit 然后将下面两行百分号之间的内容,复制进去,保存
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function yy=odefunlt(x,y) %以狼在追击过程中的横坐标为自变量
yy(1,1)=y(2);
yy(2,1)=sqrt(1+y(2).^2)./(2.*x);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
在Matlab下面输入:
tspan=100:-0.1:0.1;%以狼的x坐标为自变量
y0=[0 0];%下面只知道狼是否追上兔子,但是不易推得兔子刚刚到达窝边时,狼与兔之间的距离
[t,Y] = ode45('odefunlt',tspan,y0);
n=size(Y,1);
disp('狼的坐标(x=0.1)')
disp (Y(n,1))%通过追击曲线计算当狼的横坐标为0.1(即tspan=0.1)时,狼的纵坐标