function y1 = gen_y(myseed, Nodes)

global zeta1;
global zeta2; 
global d;


t = Nodes;

%To generate an n-by-n diagonal matrix Y and its corresponding n-by-1
%vector y. That is, the ith diagnol entry of matrix Y is equal to the ith
%entry of vector y

[n1, m1] = size(t);   %t is the matrix Nodes actually

rand('state',myseed);

if m1==2,
   y1 = zeros(n1,1);
   for i=1:n1
       if t(i,2) >= zeta1 * sin(2 * pi * zeta2 * t(i,1))+0.5 + d,
          u=rand(1,1);
          if u <= 0.95,
             y1(i,1)=1;
          else 
             y1(i,1)=-1;
          end
       elseif t(i,2) <= zeta1 * sin(2 *pi*zeta2 * t(i,1))+0.5 - d,
          u=rand(1,1);	
          if u <= 0.95,
             y1(i,1)=-1;
          else 
             y1(i,1)=1;
          end
       else 
          u=rand(1,1);	
          if u <= 0.5,
             y1(i,1)=1;
          else 
             y1(i,1)=-1;
          end
       end
   end
end












