clear all
close all
clc
% straight line 1 of the athletic track
x1=-10:0.2:10;
y1=0*x1+5;
% semi-circle 1 of the athletic track
theta=pi/2:-0.04:-pi/2;
x2=5*cos(theta)+10;
y2=5*sin(theta);
% straight line 2 of the athletic track
x3=10:-0.2:-10;
y3=0*x3-5;
% semi-circle 2 of the athletic track
theta=3*pi/2:-0.04:pi/2;
x4=5*cos(theta)-10;
y4=5*sin(theta);
% Include straight lines and semi-circles to get an entire athletic track
x=[x1 x2 x3 x4];
y=[y1 y2 y3 y4];
% Two cycles of the athletic track
x=[x x];
y=[y y];
% plot the athletic track
plot(x,y)
axis([-16,16,-6,6])
axis equal
hold on
for i=1:length(x)
k1=fix(1.1*i); % define velocity of the 1st player (uniform velocity)
if k1>length(x)
k1=length(x);
end
h1=plot(x(k1),y(k1),'Color',[1 0 0],'Marker','o','LineWidth',5); % show location of the 1st player
k2=fix(1+5*i^(0.76)); % define velocity of the 2nd player (faster at the beginning, then slower)
if k2>length(x)
k2=length(x);
end
h2=plot(x(k2),y(k2),'Color',[k2/length(x) 0 k2/length(x)],'Marker','s','LineWidth',5); % show location of the 2nd player
k3=fix(1+exp(0.012*i)); % define velocity of the 3rd player (slower at the beginning, then faster)
if k3>length(x)
k3=length(x);
end
h3=plot(x(k3),y(k3),'Color',[rand rand rand],'Marker','v','LineWidth',5); % show location of the 3rd player
pause(0.05) % pause to show the locations of players
drawnow
delete(h1)
delete(h2)
delete(h3)
end
msgbox('MATLAB编程答疑,请加QQ: 1530497909','MATLAB答疑','help')
web http://url.cn/NSFcAs -browser
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【达摩老生出品,必属精品,亲测校正,质量保证】 资源名:MATLAB_动画_龟兔赛跑_源程序代码 资源类型:matlab项目全套源码 源码说明: 全部项目源码都是经过测试校正后百分百成功运行的,如果您下载后不能运行可联系我进行指导或者更换。 适合人群:新手及有一定经验的开发人员
资源详情
资源评论
资源推荐
收起资源包目录
MATLAB_动画_龟兔赛跑_源程序代码.rar (3个子文件)
Matlab实现无约束条件下普列姆(Prim)算法.docx 14KB
MATLAB动画 龟兔赛跑 源程序代码
cartoon.m 2KB
Thumbs.db 5KB
共 3 条
- 1
阿里matlab建模师
- 粉丝: 3297
- 资源: 2784
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论1