% Generation of oscillator data

Ac=[0 1; -1 0];
Bc=[0;1];
Cc=[1 0];
Dc=0;
T=0.5;
sysC=ss(Ac,Bc,Cc,Dc);
sysD=c2d(sysC,T);

% noiseless input to the oscillator
Un=1*[ones(1,10) zeros(1,10) ones(1,10) zeros(1,11)];
% add process noise 
sqW=0.1;
U=Un+sqW*randn(size(Un));

[Yn,Tsim,Xsim]=lsim(sysD,U);
% add measurement noise
sqV=0.2;
Ym=Yn+sqV*randn(size(Yn));