No BSD License
function [x,y] = gendata(nbpts, outliers) %GENDATA function [x,y] = gendata(nbpts, outliers) % gnration de donnes y = ax+b + points aberrants % nbpts nombre total de points (30 par dfaut) % outliers pourcentage de points aberrants (1/3 par dfaut) if nargin == 0 nbpts = 30; outliers = 1/3; elseif nargin == 1 outliers = 1/3; end; x = sort(rand(1,fix(nbpts*(1-outliers)))); a = tan(pi*(rand(1)-0.5)); b = (rand-0.5); y = a.*(x+0.01.*randn(size(x)))+b; ymin = min(y); ymax = max(y); %gnration des points aberrants (outliers) : x1 = rand(1,nbpts-length(x)); y1 = ymin+rand(size(x))*(ymax-ymin); % ajout aux prcdents [x, i] = sort([x x1]); y = [y y1]; y = y(i);
Contact us at files@mathworks.com