如何用matlab画奥运五环(自学Matlab1)
1、确定五环的圆点(x,y)和半径r:
查阅奥运五环的资料可知,同一排圆心距离为2.5r,第一排圆环与第二排圆环的y相差r,因此可以确定五环的圆点,r随意设定(这里设为10);

2、画蓝、黑、红圆:
根据数学公式知x=rcos(θ),y=rsin(θ);
plot(x1+r*cos(theta),y1+r*sin(theta),'bo','Linewidth',2);%画第一个圆
hold on;
plot(x2+r*cos(theta),y2+r*sin(theta),'kd','Linewidth',2);%画第二个圆
plot(x3+r*cos(theta),y3+r*sin(theta),'rp','Linewidth',2);%画第三个圆
plot是matlab中常用的二维绘图函数,常用语法格式为plot(x,y);
‘bo’代表蓝色圆圈,‘kd’代表黑色菱形,‘rp’代表红色五角;
'Linewidth'设置线的宽度;

3、画黄、绿圆:
与步骤2同理
plot(x4+r*cos(theta),y4+r*sin(theta),'y>','Linewidth',2);%画第四个圆
plot(x5+r*cos(theta),y5+r*sin(theta),'g<','Linewidth',2);%画第五个圆

4、美化图片:
奥运五环是白色的,且不需要坐标轴;
需要用到set和axis两个函数;
set可以设置图片的各种参数,axis可以改变坐标轴;

5、完整程序:
r=10;%设定圆心半径为10,这个可以自己改;
theta=0:pi/25:2*pi;
x1=0;y1=0;%以蓝色圆圆心为起始点;
x2=x1+2.5*r;y2=y1;%设置黑圆圆心;
x3=x1+5*r;y3=y1;%设置红圆圆心;
x4=(x1+x2)/2;y4=y1-r;%设置黄圆圆心;
x5=(x2+x3)/2;y5=y4;%设置蓝圆圆心;
plot(x1+r*cos(theta),y1+r*sin(theta),'bo','Linewidth',2);hold on;%画第一个圆
plot(x2+r*cos(theta),y2+r*sin(theta),'kd','Linewidth',2);%画第二个圆
plot(x3+r*cos(theta),y3+r*sin(theta),'rp','Linewidth',2);%画第三个圆
plot(x4+r*cos(theta),y4+r*sin(theta),'y>','Linewidth',2);%画第四个圆
plot(x5+r*cos(theta),y5+r*sin(theta),'g<','Linewidth',2);%画第五个圆
text(4.5*r,-2.3*r,'万水千山走遍13','fontsize',12,'fontname','隶书','fontweight','bold')
set(0,'defaultfigurecolor','w')%使背景变成白色
axis([-1.5*r 6.5*r -2.5*r 1.5*r])%限定坐标轴范围
axis off%去掉坐标轴

6、进一步展望:
有能力的童鞋可以试着画动图(如果不动,点一下图片);
思路是:改变r,不断重新绘图;
