又称圆锥曲线,就是平面截取圆锥得到的曲线。包括:圆,椭圆,抛物线(平行于母线),双曲线(平行于轴),等
一般式:
ezplot('x^2+y^2=4');hold on;
h2=ezplot('y=x^2');set(h2,'Color','r');hold on;
h3=ezplot('2*x^2-4*y^2=8');hold on;set(h3,'Color','k');
h4=ezplot('2*x^2+4*y^2=8');hold on;set(h4,'Color','m');
legend('圆','抛物线','双曲线','椭圆');
title('圆锥曲线');grid on;axis equal;
axis([-8 8 -6 6]);
%使用legend()显示线的标签
%使用set()函数设置颜色
%标题,网格,坐标轴单位长度相等
%使用axis()设置坐标轴显示范围
%使用参数方程的形式(感觉参数方程是一种极坐标的表示)
x0=5;y0=0;%中心位置
a=10; b=5; %长短轴
theta=0:pi/100:2*pi;
x=a*cos(theta)+x0;y=b*sin(theta)+y0;%椭圆的参数方程
figure;plot(x,y);hold on;axis([-15 15 -15 15]);
双曲线:
,
为什么要加一个view????
a=4;
b=2;
theta=0:0.1:2*pi+0.1;
x=a*cos(theta);
y=b*sin(theta);
z=-5:0.5:5;
X=ones(length(z),1)*x;
Y=ones(length(z),1)*y;
Z=z'*ones(1,length(x));figure
hold on
surf(X,Y,Z)
view(18,20)