% Generates problem for system identification from real data. Data
% can be downloaded from DaISy library.

gen=input(['enter 0 for random data, 1 for CD Player arm, 2 for CSTR,\n' ...
    '3 for Hair Dryer,4 for Heat Exchanger, 5 for internet traffic,\n'...
    '6 for Flexible Robot Arm,7 for Heat Flow density, 8 for Industrial Winding,\n'...
    '9 for Glass Furnace, 10 for Industrial Dryer\n']);
  
if gen==0; 
 
elseif gen==1;
  clear
  load CD_player_arm.dat;
  U=CD_player_arm(:,1:2);
  Y=CD_player_arm(:,3:4);
  N=199; p=2; m=2;		%Size of training set used by Liu & Vandenberghe
  N=floor(size(U,1)/4);
  u=U(1:N+1,:)';
  bx=Y(1:N+1,:)';
elseif gen==2
  clear
  load cstr.dat;
  U=cstr(:,2);
  Y=cstr(:,3:4); 
  N=249; p=1;  m=2;		%Size of training set used by Liu & Vandenberghe
  N=floor(size(U,1)/4);
  u=U(1:N+1,:)';
  bx=Y(1:N+1,:)';
elseif gen==3
  clear
  load dryer.dat;
  U=dryer(:,1);
  Y=dryer(:,2);
  p=1;  m=1;  N=149;		%Size of training set used by Liu & Vandenberghe
  N=floor(size(U,1)/4);
  u=U(1:N+1,:)';
  bx=Y(1:N+1,:)';
elseif gen==4
  clear
  load exchanger.dat;
  U=exchanger(:,2);
  Y=exchanger(:,3);
  p=1;  m=1;  N=399;		%Size of training set used by Liu & Vandenberghe
  N=floor(size(U,1)/4);
  u=U(1:N+1,:)';
  bx=Y(1:N+1,:)';
elseif gen==5 % can be very large
  clear
  load dataset.dat;
  U=dataset(:,1);
  Y=dataset(:,2);
  p=1;  m=1; N=999;		%Size of training set used by Liu & Vandenberghe
  N=floor(size(U,1)/4);
  u=U(1:N+1,:)';
  bx=Y(1:N+1,:)';
elseif gen==6
  clear
  load robot_arm.dat;
  U=robot_arm(:,1);
  Y=robot_arm(:,2);
  p=1;  m=1; N= 99;		%Size of training set used by Liu & Vandenberghe
  N=floor(size(U,1)/4);
  u=U(1:N+1,:)';
  bx=Y(1:N+1,:)';
elseif gen==7
  clear
  load thermic_res_wall.dat;
  U=thermic_res_wall(:,1:2);
  Y=thermic_res_wall(:,3);
  p=2;  m=1;  N=399;		%Size of training set used by Liu & Vandenberghe
  N=floor(size(U,1)/4);
  u=U(1:N+1,:)';
  bx=Y(1:N+1,:)';
elseif gen==8
  clear
  load winding.dat;
  U=winding(:,1:5);
  Y=winding(:,6:7);
  p=5;  m=2; N=249;		%Size of training set used by Liu & Vandenberghe
  N=floor(size(U,1)/4);
  u=U(1:N+1,:)';
  bx=Y(1:N+1,:)';
elseif gen==9
  clear
  load glassfurnace.dat;
  U=glassfurnace(:,2:4);
  Y=glassfurnace(:,5:10);
  p=3;  m=6;  N=149;	%#MEASUREMENTS FOR IDENTIFICATION	%Size of training set used by Liu & Vandenberghe
  N=floor(size(U,1)/4);
  u=U(1:N+1,:)';  
  bx=Y(1:N+1,:)';
elseif gen==10
  clear
  load dryer2.dat;
  U=dryer2(:,2:4);
  Y=dryer2(:,5:7);
  p=3;  m=3; N=249;		%Size of training set used by Liu & Vandenberghe
  N=floor(size(U,1)/4);
  u=U(1:N+1,:)';
  bx=Y(1:N+1,:)';
end

r=41;
U=Hrx(u,r);
U=null(U);
q=size(U,2);

save realP8  m N p r U bx