function transHoptToHYSYS(loadname,filename,NoMeas)
load(loadname,'Hopt','y_nom','c_nom')

serv = actxserver('Hysys.Application.2006.5');
HyCase = serv.SimulationCases.Open([pwd,filename]);
HyCase.Activate;
Col = HyCase.Flowsheet.Operations.Item('T-100');
y = Col.ColumnFlowsheet.TemperaturesValue;
y = y(2:end-1);
y_nom = y;

%% put the values in HYSYS file

beta = Hopt;

sum1 = 0; sum2 = 0; sum1p = 0; sum2p = 0; 

r = 0 + 0.1 .* randn(36,1);

beta = beta(2:end,:)';
r = 0 + 0.1 .* randn(36,1);


for i = 1:length(y)
   HyCase.Flowsheet.Operations.Item('SPRDSHT-1').Cell(['B',num2str(i+4)]).CellValue = 0;
   HyCase.Flowsheet.Operations.Item('SPRDSHT-1').Cell(['C',num2str(i+4)]).CellValue = 0;
   
   HyCase.Flowsheet.Operations.Item('SPRDSHT-1').Cell(['H',num2str(i+4)]).CellValue = 0;
   HyCase.Flowsheet.Operations.Item('SPRDSHT-1').Cell(['I',num2str(i+4)]).CellValue = 0;
   HyCase.Flowsheet.Operations.Item('SPRDSHT-1').Cell(['Q',num2str(i+4)]).CellValue = 0;
end

counter=1;
for i = NoMeas:NoMeas:size(y,2)-1
   HyCase.Flowsheet.Operations.Item('SPRDSHT-1').Cell(['A',num2str(i+4)]).CellValue = y(i); 
   HyCase.Flowsheet.Operations.Item('SPRDSHT-1').Cell(['Q',num2str(i+4)]).CellValue = r(i);
   
   HyCase.Flowsheet.Operations.Item('SPRDSHT-1').Cell(['B',num2str(i+4)]).CellValue = Hopt(1,counter);
   HyCase.Flowsheet.Operations.Item('SPRDSHT-1').Cell(['C',num2str(i+4)]).CellValue = Hopt(2,counter);
   
   HyCase.Flowsheet.Operations.Item('SPRDSHT-1').Cell(['D',num2str(i+4)]).CellValue = ...
       HyCase.Flowsheet.Operations.Item('SPRDSHT-1').Cell(['A',num2str(i+4)]).CellValue * ...
       HyCase.Flowsheet.Operations.Item('SPRDSHT-1').Cell(['B',num2str(i+4)]).CellValue;
  
   HyCase.Flowsheet.Operations.Item('SPRDSHT-1').Cell(['E',num2str(i+4)]).CellValue = ...
       HyCase.Flowsheet.Operations.Item('SPRDSHT-1').Cell(['A',num2str(i+4)]).CellValue * ...
       HyCase.Flowsheet.Operations.Item('SPRDSHT-1').Cell(['C',num2str(i+4)]).CellValue;
   
   sum1 = sum1 + HyCase.Flowsheet.Operations.Item('SPRDSHT-1').Cell(['D',num2str(i+4)]).CellValue;
   sum2 = sum2 + HyCase.Flowsheet.Operations.Item('SPRDSHT-1').Cell(['E',num2str(i+4)]).CellValue;
   
   HyCase.Flowsheet.Operations.Item('SPRDSHT-1').Cell(['H',num2str(i+4)]).CellValue = Hopt(1,counter);
   HyCase.Flowsheet.Operations.Item('SPRDSHT-1').Cell(['I',num2str(i+4)]).CellValue = Hopt(2,counter);
 
   counter=counter+1;
end

HyCase.Flowsheet.Operations.Item('SPRDSHT-1').Cell('F5').CellValue = sum1;
HyCase.Flowsheet.Operations.Item('SPRDSHT-1').Cell('F6').CellValue = sum2;


