MATLAB绘制圆变形动态图

发布时间:2021-02-26 01:32:47

MATLAB绘制圆变形动态图

网友回答

function h=circle(r,x0,y0,C,Nb)
% CIRCLE adds circles to the current plot
% %% r 圆之半径,可为列矩阵,代表可同时绘制许多同心或同性质的圆.
%% -x0,y0 圆心之座标,可为矩阵,代表可同时绘制许多不同圆心位置之圆.
%% -C 圆之颜色,不说明时,由指令依序指定,亦可作向量指定.
%% -Nb 绘圆时所用之点数,可用向量,若不指定,则以300点为预设值.
%% Check the number of input arguments
switch nargin
case 0r=[];x0=[];y0=[];C=[];Nb=[];
case 1x0=[];y0=[];C=[];Nb=[];
case 2y0=zeros(1,length(x0));C=[];Nb=[];
case 3C=[];Nb=[];
case 4Nb=[];
endif length(x0)~=length(y0),
if length(y0)==1,
y0=ones(1,length(x0))*y0;
elseif length(x0)==1,
x0=ones(1,length(y0))*x0;
elseerror('The lengths of x0 and y0 must be identical');
end;end;% set up the default values
if isempty(r),r=1;end;
if isempty(x0),x0=0;end;
if isempty(y0),y0=0;end;
if isempty(Nb),Nb=300;end;
if isempty(C),C=get(gca,'colororder');end;
if isstr(C),C=C(:);end;
% work on the variable sizes
x0=x0(:);
y0=y0(:);
r=r(:);
Nb=Nb(:);
% how many rings are plottet
if length(r)~=length(x0)
maxk=length(r)*length(x0);
elsemaxk=length(r);
end;route=0;
if length(x0)==1,route=1; end
if length(r)==1,route=2; end
if length(x0)==length(r),route=3; end
% drawing loop
for k=1:maxk
switch route
case 1xpos=x0;
ypos=y0;rad=r(k);case 2xpos=x0(k);ypos=y0(k);rad=r;case 3xpos=x0(k);
以上问题属网友观点,不代表本站立场,仅供参考!