在MatLab中画彩虹
1、思路1. 画8个不同半径的圆2. 定义8中不同的填充颜色3. 利用fill填色,从半径最大的开始,由外往内,这样做可以让后面填色的覆盖之前填色
2、具体代码figure;pause(5);t=0:0.001:pi;x=8*cos(t);y=8*s足毂忍珩in(t);fill(x,y,'r');hold on;x=7*cos(t);y=7*sin(t);patch(x,y,[1 0.5 0]);hold on;x=6*cos(t);y=6*sin(t);fill(x,y,'y');hold on;x=5*cos(t);y=5*sin(t);fill(x,y,'g');hold on;x=4*cos(t);y=4*sin(t);patch(x,y,[ 0.5843 0.8157 0.9882]);hold on;x=3*cos(t);y=3*sin(t);fill(x,y,'b');hold on;x=2*cos(t);y=2*sin(t);patch(x,y,[0.4039 0.0078 0.3686]);t=0:0.01:pi;x=cos(t);y=sin(t);fill(x,y,'w');plot([-1 1],[0 0],'w');axis equal;
3、结果展示
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:61
阅读量:76
阅读量:86
阅读量:47
阅读量:23