clear all  % Clar memory
clc        % Clear screen


 U=prbs1(500,50,100);  % Input experiment
 
 Y=sys_sim(U);         % Simulate system
 
 % Plot input and output data
 figure(1)
 subplot(211), plot(U), ylabel('u_k')
 title('The input output data')
 subplot(212), plot(Y), ylabel('y_k')
 xlabel('Samples')

 % Calculating the Hankel matrices in the
 % matrix equation
 L=2; g=1; J=L;
 
 [A,D,OL]=idsys(Y,U,L,g,J)
 
 
 % Use DSR to find complete model
 [a,b,d,e,c,f,x0]=dsr(Y,U,L,g,J);
 
 % Simulate DSR model using DSRSIM
 Ym=dsrsim(a,b,d,e,U,x0);
 
 % Plot model output Ym against Y
 figure(2)
 plot([Y Ym]), grid