mu = [11,10]; sigma = [5,0;0 5]; rng default % For reproducibility r1 = mvnrnd(mu,sigma,100); mu = [15,15]; sigma = [2,0;0,5]; r2 = mvnrnd(mu,sigma,100); mu = [20,15]; sigma = [5,0;0,2]; r3 = mvnrnd(mu,sigma,100); X=[r1;r2;r3]; y=[ones(size(r1,1),1);2*ones(size(r2,1),1);3*ones(size(r3,1),1)]; xrange = [min(X(:,1))-1 max(X(:,1))+1]; yrange = [min(X(:,2))-1 max(X(:,2))+1];