TP-traitement-audio-visuel/TP3_dams/donnees_n.m
2023-06-22 20:47:16 +02:00

57 lines
1.5 KiB
Matlab

clear;
close all;
taille_ecran = get(0,'ScreenSize');
L = taille_ecran(3);
H = taille_ecran(4);
% Paramètres :
taille = 20;
echelle = [-taille taille -taille taille];
n = 4;
colors = rand(n,3);
parametres_VT = zeros(n,5);
D_app = [];
figure('Name','Donnees d''apprentissage','Position',[0,0,0.33*L,0.5*H]);
hold on;
for i = 1:n
% Tirage aléatoire des paramètres de la première ellipse :
a = 2*taille/5*(rand+1); % Demi grand axe
e = rand; % Excentricité
x_C = (taille-a)*(4*rand-2); % Abscisse du centre
y_C = (taille-a)*(4*rand-2); % Ordonnée du centre
theta = 2*pi*rand; % Angle du grand axe
b = a*sqrt(1-e^2);
R = [cos(theta) -sin(theta) ; sin(theta) cos(theta)];
parametres_VT(i,:) = [a,e,x_C,y_C,theta];
% Tracé de la première ellipse (trait noir) :
n_affichage = 100;
theta_affichage = 2*pi/n_affichage:2*pi/n_affichage:2*pi;
P = R*[a*cos(theta_affichage);b*sin(theta_affichage)]+[x_C;y_C]*ones(1,n_affichage);
x = P(1,:);
y = P(2,:);
plot([x x(1)],[y y(1)],'b-','LineWidth',3);
xlabel('$x$','Interpreter','Latex');
ylabel('$y$','Interpreter','Latex');
axis([-taille taille -taille taille]);
axis equal;
% Calcul des données d'apprentissage (bruit blanc sur x et sur y) :
sigma = 1;
n_app = 200;
theta_app = 2*pi*rand(1,n_app);
D_app_i = R*[a*cos(theta_app);b*sin(theta_app)]+[x_C;y_C]*ones(1,n_app)+sigma*randn(2,n_app);
D_app = [D_app D_app_i];
end
% Tracé des données d'apprentissage (croix bleues) :
plot(D_app(1,:),D_app(2,:),'+b','MarkerSize',10,'LineWidth',2);