I will find an xy dataset satisfying an implicit equation.
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
kadir can erbas
am 25 Sep. 2023
Bearbeitet: Bruno Luong
am 26 Sep. 2023
(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?
0 Kommentare
Akzeptierte Antwort
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(:)]
h2=plot(x, y, '.r');
legend([h1 h2],'approximation', 'accurate')
figure
plot(f(x,y)) % should be close to 0
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Calculus 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!