⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ellipse.m

📁 很多matlab的源代码
💻 M
字号:
function c=ellipse(s,z,ty)
% ELLIPSE Plot an ellipse.
%
%         ELLIPSE(S,Z,TY) plots an ellipse with 
%         S = [xs, ys] = [x-semiaxis, y-semiaxis]
%	  Z = [x0 y0] = center  [Default  Z = [0 0]].
%         If Z is a scalar, Z is chosen as: Z = [Z,Z].
%	  TY is line type [Default: '-'].
%
%         ELLIPSE(A) plots circle of radius A.
%
%	  P=ELLIPSE(...) returns values for plotting in Y but does not plot.
%	  P is a two column matrix. To plot, use plot(P(:,1),P(:,2)) 
%
%         ELLIPSE (with no input arguments) invokes the following example:
%
%         >>axis('square')  
%         >>ellipse([2 3]) %ellipse with x-semiaxis=2, y-semiaxis=3


% ADSP Toolbox: Version 2.0 
% For use with "Analog and Digital Signal Processing", 2nd Ed.
% Published by PWS Publishing Co.
%
% Ashok Ambardar, EE Dept. MTU, Houghton, MI 49931, USA
% http://www.ee.mtu/faculty/akambard.html
% e-mail: akambard@mtu.edu
% Copyright (c) 1998


if nargin==0,help ellipse,disp('Strike a key to see results of the example')
pause,v=exist('version');ax=[-3 3 -3 3];if v~=5,axis('square'),axis(ax),end,
ellipse([2 3]),if v==5,axis('square'),axis(ax)
else,axis('normal'),end,hold off,return,end

if nargin==1,z=[0 0];ty='-';
elseif nargin==2,if isstr(z),ty=z;z=[0 0];else,ty='-';end
else,end
a=s(1);if length(s)==2,b=s(2);else,b=a;end
z1=z(1);
if length(z)==2,z2=z(2);else,z2=z1;end
y=-a:a/100:a;x=b*sqrt(a*a-y.*y)/a;
x=[-x x];y=[y fliplr(y)];
x=x+z2;y=y+z1;
if nargout==0,plot(y,x,ty),else,c=[y(:) x(:)];end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -