繁体   English   中英

在Matlab中绘制2变量隐式函数而无需使用fimplicit或ezplot

[英]Plotting a 2-variable implicit function in MatLab WITHOUT fimplicit or ezplot

我的任务是绘制隐式函数x ^ 2 + y ^ 2 = 1 + 4.5sin ^ 2(xy),并且不允许使用诸如fimplicit或ezplot之类的“隐式绘制函数”。

我被plot,polarplot和fzero卡住了,就是这样。

这些说明似乎暗示着转换为极性函数是关键,但是经过几个小时的尝试,阅读和谷歌搜索之后,我仍然不知道该怎么做。

将x和y转换为其极性形式仍然不能解决所有theta值的r问题,所以我很困惑。

任何帮助将不胜感激。

干杯!

由于不能同时使用轮廓线,弯曲线或ezplot。

我知道您的老师希望您使用implicit function theorem 您可以找到它的定义隐函数定理

我认为您应该从Wikipedia文章中的The circle example开始。

请记住,您只需要为图的一部分解决此问题,其余只是对称性。

您的起点应该是(x = 0,y = 1),这是一个解决方案。

然后你会发现

dy/dx = (2x+9ysin(xy)cos(xy))/(2y+9xsin(xy)cos(xy))

您认识一个简单的ODE

最简单的解决方法是从(x = 0,y = 1)开始(这是一个解决方案),选择一个dx步骤(0.01),然后保存算法中的所有点

y <- y + (2x+9ysin(xy)cos(xy))/(2y+9xsin(xy)cos(xy))*dx  
x <- x + dx

直到遇到麻烦(雅各布式的决定因素为0)

对于提示,我离开剧情:

我相信当x在[-3,3]中并且对于y时,您的隐式函数都将给出结果。

所以

[x,y]=meshgrid([-3:0.01:3],[-3:0.01:3])
z= x.^2 + y.^2 - 1.0 - 4.5.*sin(x.*y).^2
v = [0,0];
contour(x,y,z,v)

应该给你像

在此处输入图片说明

theta = linspace(0, 2.*pi, 1000);

for i = 1:length(theta) % Want to check every angle in theta.

% asign x = r*cos(theta) and y = r*sin(theta. You want to set the equation 
% equal to 0.
f = @(r)1 + 4.5.*(sin(r.^2.*(cos(theta(i)) .*sin(theta(i))))).^2 - r.^2;

r(i) = fzero(f, 3); % Solves the equation. The value 3 is just an 
% approximation of r, set it to any number you like. It just can't be too high.

% Make the two coordinates x and y. Asign them to their polar coordinates 
% using r.
x(i) = r(i).*cos(theta(i)); 
y(i) = r(i).*sin(theta(i));
end

plot(x,y)
grid on
axis equal
axis([-4 4 -4 4])

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM