I will find an xy dataset satisfying an implicit equation.

2 Ansichten (letzte 30 Tage)
(x^2 + y^2)^3 + (15*x + 3.3*y)*(x^2 + y^2)^2 + (62.5*x^2 + 20*x*y - 8.37*y^2)*(x^2 + y^2) - 17*x^3 + 11*x^2*y + 17*x*y^2 - 11*y^3 + 432*x^2 - 24*x*y + 67*y^2 - 82*x + 400*y - 1037=0
I have the above equation and I want to obtain 200 xy points satisfying the equation. How can I find?

Akzeptierte Antwort

Bruno Luong
Bruno Luong am 25 Sep. 2023
Bearbeitet: Bruno Luong am 26 Sep. 2023
f = @(x,y)(x.^2 + y.^2).^3 + (15.*x + 3.3.*y).*(x.^2 + y.^2).^2 + (62.5.*x.^2 + 20.*x.*y - 8.37.*y.^2).*(x.^2 + y.^2) - 17.*x.^3 + 11.*x.^2.*y + 17.*x.*y.^2 - 11.*y.^3 + 432.*x.^2 - 24.*x.*y + 67.*y.^2 - 82.*x + 400.*y - 1037;
n = 8;
while true
xg = linspace(-8,8,n+1);
yg = linspace(-8,8,n+1);
[Xg,Yg] = meshgrid(xg,yg);
z=f(Xg,Yg);
close all
a = contour(Xg,Yg,z,[0 0]);
if a(2,1) >= 200
break
end
n = 2*n;
end
xy = a(:,2:end);
x = xy(1,:);
y = xy(2,:);
hold on
axis equal
h1=plot(x, y, '.b');
for k=1:size(xy,2)
if ismember(x(k),xg)
y(k) = fzero(@(y) f(x(k),y), y(k));
else
x(k) = fzero(@(x) f(x,y(k)), x(k));
end
end
xy = [x(:), y(:)]
xy = 253×2
-2.4309 -6.7500 -2.5000 -6.7679 -2.6250 -6.7968 -2.7500 -6.8211 -2.8750 -6.8409 -3.0000 -6.8561 -3.1250 -6.8667 -3.2500 -6.8727 -3.3750 -6.8739 -3.5000 -6.8704
h2=plot(x, y, '.r');
legend([h1 h2],'approximation', 'accurate')
figure
plot(f(x,y)) % should be close to 0

Weitere Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by