I will find an xy dataset satisfying an implicit equation.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
kadir can erbas
le 25 Sep 2023
Modifié(e) : Bruno Luong
le 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 commentaires
Réponse acceptée
Bruno Luong
le 25 Sep 2023
Modifié(e) : Bruno Luong
le 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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!