donnees; n_tests = 1000; % Estimation du rayon et de la position du centre : [C_estime,R_estime] = estimation_2(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_estime*cos(theta_cercle); y_cercle_estime = C_estime(2)+R_estime*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_estime] = estimation_2(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, n_tests); y = repmat(y_donnees_bruitees.', 1, n_tests, n_tests); x_rand = repmat((rand(1, n_tests)*2 - 1) + G(1), length(x_donnees_bruitees), 1, n_tests); y_rand = repmat((rand(1, n_tests)*2 - 1) + G(2), length(y_donnees_bruitees), 1, n_tests); r_rand = rand(1, 1, n_tests) - 1/2 + R_moyen; R = repmat(r_rand, length(x_donnees_bruitees), n_tests, 1); dist = (sqrt((x-x_rand).^2 + (y-y_rand).^2) - R).^2; somme = reshape(sum(dist), [n_tests, n_tests]); [min_val, idx] = min(somme(:)); [row, col] = ind2sub(size(somme), idx); C_estime = [ x_rand(1, row ) y_rand(1, row ) ]; R_estime = r_rand(col); end