这段程序可以画五个排列类似五环的五个相切圆:
r=10;
x=[0 20 40 10 30]
y=[0 0 0 -10sqrt(3) -10sqrt(3)]
for i=1:5;
t=0:pi/10:2pi;
x0=x(i)+rcos(t);
y0=y(i)+rsin(t);
plot(x0,y0,'r-');
hold on;
end
hold off
主程序
N =80;x = rand(N,1);
y = rand(N,1);
r = rand(N,1)01;
FaceColor = 'r';
EdgeColor ='b';
Circle(x,y,r)
函数程序
function Circle(x,y,r,FaceColor,EdgeColor)if nargin==5
for i=1:numel(x)
CirFaceColor = FaceColor;
CirEdgeColor = EdgeColor;
CirPosition = [x(i)-r(i) y(i)-r(i) 2r(i) 2r(i)];
CirCurvature = [1 1];
rectangle(Cir);
hold on
axis equal
axis off
end
else
FaceColor = jet(numel(x));
EdgeColor = jet(numel(x));
for i=1:numel(x)
CirFaceColor = FaceColor(randi([1,numel(x)],1,1),:);
CirEdgeColor = EdgeColor(randi([1,numel(x)],1,1),:);
CirPosition = [x(i)-r(i) y(i)-r(i) 2r(i) 2r(i)];
CirCurvature = [1 1];
rectangle(Cir);
hold on
axis equal
axis off
end
end
end
syms a b;
ezplot( (2-a)^2+(50-b)^2 );
为什么这样画只能出现一个点?不能出现一个圆
答:这时圆没有半径, r=0;
syms a b;
ezplot( (2-a)^2+(50-b)^2-1 );
解答:(Matlab R2013b)
>> syms a b
>> h=ezplot((2-a)^2+(50-b)^2==1,[1,3,49,51]);axis equal;
>> set(h,'color','r');
>> set(h,'linewidth',2);
参考资料:
>>help sym/ezplot
找Examples:
syms x y t
ezplot(cos(x))
ezplot(cos(x), [0, pi])
ezplot(x^2 - y^2 == 1)
ezplot(x^2 + y^2 == 1,[-125,125],3); axis equal
ezplot(1/y-log(y)+log(-1+y)+x == 1)
ezplot(x^3 + y^3 - 5xy == 1/5,[-3,3])
ezplot(x^3 + 2x^2 - 3x + 5 == y^2)
ezplot(sin(t),cos(t))
ezplot(sin(3t)cos(t),sin(3t)sin(t),[0,pi])
以上就是关于编写matlab源程序画出五个相切的单位圆,五个单位圆排列形状类似五环。全部的内容,包括:编写matlab源程序画出五个相切的单位圆,五个单位圆排列形状类似五环。、关于matlab画圆、用matlab怎么画圆等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)