% Generate data set
% test 1 parallel planes
% lambda = [0 0 1];
[x,y] = meshgrid(-10:0.1:10, -10:0.1:10);
[m,n] = size(x);
z = 20*ones(m,n);
% add some noise;
z = z + rand(m,n);
pm = randperm(m);
pn = randperm(n);
num = 100;
data = zeros(3, num);
data(1,:) = x(1, pn(1:num));
data(2,:) = y(pm(1:num), 1);
data(3,:) = z(1, pn(1:num));
% figure
% scatter3(data(1,:), data(2,:), data(3,:), 'filled'), view(-60,60);
% % add another plane
% % lambda = [0 0 1/10];
% z = 20*ones(m,n);
% % z = z + rand(m,n);
% pm = randperm(m);
% pn = randperm(n);
% data(1,101:200) = x(1, pn(1:num));
% data(2,101:200) = y(pm(1:num), 1);
% data(3,101:200) = z(1, pn(1:num));
% figure
% scatter3(data(1,101:200), data(2,101:200), data(3,101:200), 'filled'), view(-60,60);

% test 1 parallel planes
% lambda = [0 1 0];
[x,z] = meshgrid(-10:0.1:10, -10:0.1:10);
y = 20*ones(m,n);
y = y + rand(m,n);
pm = randperm(m);
pn = randperm(n);
data(1,101:200) = x(1, pn(1:num));
data(2,101:200) = y(1, pn(1:num));
data(3,101:200) = z(pm(1:num), 1);
% figure
% scatter3(data(1,101:200), data(2,101:200), data(3,101:200), 'filled'), view(-60,60);
% % add another plane
% % lambda = [0 1/5 0];
% y = 20*ones(m,n);
% % y = y + rand(m,n);
% pm = randperm(m);
% pn = randperm(n);
% data(1,301:400) = x(1, pn(1:num));
% data(2,301:400) = y(1, pn(1:num));
% data(3,301:400) = z(pm(1:num), 1);
% figure
% scatter3(data(1,301:400), data(2,301:400), data(3,301:400), 'filled'), view(-60,60);

% test 1 parallel planes
% lambda = [1 0 0];
[z,y] = meshgrid(-10:0.1:10, -10:0.1:10);
x = 20*ones(m,n);
x = x + rand(m,n);
pm = randperm(m);
pn = randperm(n);
num = 100;
data(1,201:300) = x(1, pn(1:num));
data(2,201:300) = y(pm(1:num), 1);
data(3,201:300) = z(1, pn(1:num));
% figure
% scatter3(data(1,201:300), data(2,201:300), data(3,201:300), 'filled'), view(-60,60);
% % add another plane
% % lambda = [1/3 0 0]
% x = 20*ones(m,n);
% % x = x + rand(m,n);
% pm = randperm(m);
% pn = randperm(n);
% num = 100;
% data(1,501:600) = x(1, pn(1:num));
% data(2,501:600) = y(pm(1:num), 1);
% data(3,501:600) = z(1, pn(1:num));
% figure
% scatter3(data(1,501:600), data(2,501:600), data(3,501:600), 'filled'),
% view(-60,60);



[z,y] = meshgrid(-10:0.1:10, -10:0.1:10);
x = -10*ones(m,n);
x = x + rand(m,n);
pm = randperm(m);
pn = randperm(n);
num = 100;
data(1,301:400) = x(1, pn(1:num));
data(2,301:400) = y(pm(1:num), 1);
data(3,301:400) = z(1, pn(1:num));

[x,y] = meshgrid(-10:0.1:10, -10:0.1:10);
z = -10*ones(m,n);
z = z + rand(m,n);
pm = randperm(m);
pn = randperm(n);
num = 100;
data(1,401:500) = x(1, pn(1:num));
data(2,401:500) = y(pm(1:num), 1);
data(3,401:500) = z(1, pn(1:num));

[x,z] = meshgrid(-10:0.1:10, -10:0.1:10);
y = -10*ones(m,n);
y = y+rand(m, n);
pm = randperm(m);
pn = randperm(n);
num = 100;
data(1,501:600) = x(1, pn(1:num));
data(2,501:600) = y(1, pn(1:num));
data(3,501:600) = z(pm(1:num), 1);
%%
savefile = 'dataN4';
save(savefile, 'data');