36 lines
1.3 KiB
Mathematica
36 lines
1.3 KiB
Mathematica
|
donnees;
|
||
|
|
||
|
n_tests = 500;
|
||
|
|
||
|
% Estimation de la position du centre :
|
||
|
[C_estime,R_moyen] = estimation_1(x_donnees_bruitees,y_donnees_bruitees,n_tests);
|
||
|
|
||
|
% Affichage du cercle estime :
|
||
|
n_points_cercle = 100;
|
||
|
theta_cercle = 2*pi/n_points_cercle:2*pi/n_points_cercle:2*pi;
|
||
|
x_cercle_estime = C_estime(1)+R_moyen*cos(theta_cercle);
|
||
|
y_cercle_estime = C_estime(2)+R_moyen*sin(theta_cercle);
|
||
|
plot(x_cercle_estime([1:end 1]),y_cercle_estime([1:end 1]),'b','LineWidth',3);
|
||
|
lg = legend(' Cercle initial', ...
|
||
|
' Donnees bruitees', ...
|
||
|
' Cercle estime', ...
|
||
|
'Location','Best');
|
||
|
|
||
|
function [C_estime, R_moyen] = estimation_1(x_donnees_bruitees, y_donnees_bruitees, n_tests)
|
||
|
|
||
|
G = mean( [ x_donnees_bruitees.' y_donnees_bruitees.' ] );
|
||
|
R_moyen = mean( sqrt((x_donnees_bruitees.'-G(1)).^2 + (y_donnees_bruitees.'-G(2)).^2) );
|
||
|
|
||
|
x = repmat(x_donnees_bruitees.', 1, n_tests);
|
||
|
y = repmat(y_donnees_bruitees.', 1, n_tests);
|
||
|
|
||
|
x_rand = repmat((rand(1, n_tests)*R_moyen - R_moyen/2) + G(1), length(x_donnees_bruitees), 1);
|
||
|
y_rand = repmat((rand(1, n_tests)*R_moyen - R_moyen/2) + G(2), length(y_donnees_bruitees), 1);
|
||
|
|
||
|
dist = (sqrt((x-x_rand).^2 + (y-y_rand).^2) - R_moyen).^2;
|
||
|
|
||
|
[min_val, min_index] = min( sum( dist ) );
|
||
|
|
||
|
C_estime = [ x_rand(1, min_index) y_rand(1, min_index) ];
|
||
|
|
||
|
end
|