给出焦点和距离差使用MATLAB绘制双曲线

设两焦点分别为 e 1 , e 2 e_1,e_2 ,一个动点 M M 满足到 e 1 , e 2 e_1,e_2 的距离差为常数,即
M e 1 M e 2 = d ||\overrightarrow{Me_1}|-|\overrightarrow{Me_2}||=d
该动点的轨迹为双曲线。
该文章使用 M A T L A B MATLAB 中的 e z p l o t ( ) ezplot() 函数绘制参数方程的曲线,在其帮助文档里,对含参方程的绘制方法说明如下:

If your function has additional parameters, for example k in myfun:
function z = myfun(x,y,k)
z = x.^k - y.^k - 1;
then you can use an anonymous function to specify that parameter:
ezplot(@(x,y)myfun(x,y,2))

myplot(-3,0,3,0,1)
myplot(-3,0,4,5,1.5)
myplot(-3,0,2,10,3)


function  myplot(x1,y1,x2,y2,d) %(x1,y1),(x2,y2)为焦点,d为距离差
 function z = myfun(x,y,x1,y1,x2,y2,d)
        z =abs (sqrt((x-x1)^2+(y-y1)^2)-sqrt((x-x2)^2+(y-y2)^2))-d;
   end
  h = ezplot(@(x,y)myfun(x,y,x1,y1,x2,y2,d)); %myfun()中,x1,y1,x2,y2,d为参数
  set(h,'Color',[rand(),rand(),rand()])
  hold on
end

如图:
在这里插入图片描述

发布了3 篇原创文章 · 获赞 1 · 访问量 8576

猜你喜欢

转载自blog.csdn.net/qq_37930244/article/details/104761896