function S=Make_Sv()

GlobalVars;
S=speye(NVar);

% Stream variables scaling
i=1; % Stream number
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.1 .1 0.3 0.5 0.2]));  % Stream composition
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 1 1 1]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=0.25;       % Molar flow 
   S(ix(NC+1),ix(NC+1))=1;          % Molar flow 
   S(ix(NC+2),ix(NC+2))=393;        % Temperature
   S(ix(NC+3),ix(NC+3))=10;         % Pressure

i=2; % Stream number
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.9 0.02 0.02 0.02 0.01]));  % Stream composition
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 1 1 1]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=0.8;        % Molar flow 
   S(ix(NC+1),ix(NC+1))=1;          % Molar flow 
   S(ix(NC+2),ix(NC+2))=800;        % Temperature
   S(ix(NC+3),ix(NC+3))=10;         % Pressure

i=3; % Stream number
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.02 0.003 0.30 0.50 0.20]));  % Stream composition
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 1 1 1]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=0.25;       % Molar flow 
   S(ix(NC+2),ix(NC+2))=358;        % Temperature
   S(ix(NC+3),ix(NC+3))=10;         % Pressure

i=4; % Stream number
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.02 0.003 0.30 0.50 0.20]));  % Stream composition
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 1 1 1]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=1;       % Molar flow 
   S(ix(NC+2),ix(NC+2))=800;        % Temperature
   S(ix(NC+3),ix(NC+3))=10;         % Pressure

i=5; % Stream number
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.7 0.02 0.09 0.15 0.1]));
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 1 1 1]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=1;          % Molar flow 
   S(ix(NC+2),ix(NC+2))=800;        % Temperature
   S(ix(NC+3),ix(NC+3))=10;         % Pressure

i=6; % Stream number
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.7 0.02 0.09 0.15 0.1]));
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 1 1 1]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=1;          % Molar flow 
   S(ix(NC+2),ix(NC+2))=500;        % Temperature
   S(ix(NC+3),ix(NC+3))=10;         % Pressure

for i=7:15 %Reactor #1
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.7 0.02 0.09 0.15 0.1]));
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 1 1 1]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=1;          % Molar flow 
   S(ix(NC+2),ix(NC+2))=800;        % Temperature
   S(ix(NC+3),ix(NC+3))=10;         % Pressure
end

i=16; % Stream number
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.7 0.02 0.09 0.15 0.1]));
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 1 1 1]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=1;          % Molar flow 
   S(ix(NC+2),ix(NC+2))=800;        % Temperature
   S(ix(NC+3),ix(NC+3))=10;         % Pressure

for i=17:26 %Reactor #2
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.75 0.02 0.07 0.08 0.12]));
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 1 1 1]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=1;          % Molar flow 
   S(ix(NC+2),ix(NC+2))=800;        % Temperature
   S(ix(NC+3),ix(NC+3))=10;         % Pressure
end

i=27; % Stream number
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.7 0.02 0.09 0.15 0.1]));
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 1 .5 1]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=1;          % Molar flow 
   S(ix(NC+2),ix(NC+2))=800;        % Temperature
   S(ix(NC+3),ix(NC+3))=10;         % Pressure

i=28; % Stream number
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.7 0.02 0.09 0.15 0.1]));
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 1 .1 1]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=1;          % Molar flow 
   S(ix(NC+2),ix(NC+2))=600;        % Temperature
   S(ix(NC+3),ix(NC+3))=10;         % Pressure
   
i=29; % Stream number
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.7 0.02 0.09 0.15 0.1]));
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 1 .1 1]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=1;          % Molar flow 
   S(ix(NC+2),ix(NC+2))=700;        % Temperature
   S(ix(NC+3),ix(NC+3))=10;         % Pressure

for i=30:37   %Reactor #3
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.8 0.02 0.05 0.03 0.14]));
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 1 .1 1]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=1;         % Molar flow 
   S(ix(NC+2),ix(NC+2))=800;      % Temperature
   S(ix(NC+3),ix(NC+3))=10;        % Pressure
end

i=38; % Stream number
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.7 0.02 0.09 0.15 0.1]));
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 1 .1 1]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=1;          % Molar flow 
   S(ix(NC+2),ix(NC+2))=800;        % Temperature
   S(ix(NC+3),ix(NC+3))=10;         % Pressure

i=39; % Stream number
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.7 0.02 0.09 0.15 0.1]));
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 1 .1 1]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=1;          % Molar flow 
   S(ix(NC+2),ix(NC+2))=600;        % Temperature
   S(ix(NC+3),ix(NC+3))=10;         % Pressure

i=40; % Stream number
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.7 0.02 0.09 0.15 0.1]));
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 1 .1 1]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=1;          % Molar flow 
   S(ix(NC+2),ix(NC+2))=700;        % Temperature
   S(ix(NC+3),ix(NC+3))=10;         % Pressure

for i=40:48 % Reactor #4
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.8 0.025 0.05 0.01 0.14]));
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 1 .1 1]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=1;          % Molar flow 
   S(ix(NC+2),ix(NC+2))=800;        % Temperature
   S(ix(NC+3),ix(NC+3))=10;         % Pressure
end

i=49; % Stream number 1
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.9 0.025 0.025 0.002 0.06]));  % Stream composition
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 .3 .3 .3]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=1;         % Molar flow 
   S(ix(NC+2),ix(NC+2))=380;       % Temperature
   S(ix(NC+2),ix(NC+2))=800;      % Temperature
   S(ix(NC+3),ix(NC+3))=8;         % Pressure

i=50; % Stream number 1
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.01 0.002 0.2 0.03 0.7]));  % Stream composition
   S(ix(1:NC),ix(1:NC))=sparse(diag([5 5 5 5 5]));  % Stream composition
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 2 2 1]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=1;          % Molar flow 
   S(ix(NC+2),ix(NC+2))=500;       % Temperature
   S(ix(NC+3),ix(NC+3))=8;          % Pressure
   
i=51; % Stream number 1
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.95 0.025 0.002 0.0001 0.003]));  % Stream composition
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 1 1 1]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=1;         % Molar flow 
   S(ix(NC+2),ix(NC+2))=295;       % Temperature
   S(ix(NC+2),ix(NC+2))=500;       % Temperature
   S(ix(NC+3),ix(NC+3))=8;         % Pressure

i=52; % Stream number 1
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.01 0.01 0.25 0.03 0.7]));  % Stream composition
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 1 1 1]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=0.25;       % Molar flow 
   S(ix(NC+2),ix(NC+2))=370;        % Temperature
   S(ix(NC+2),ix(NC+2))=500;       % Temperature
   S(ix(NC+3),ix(NC+3))=8;          % Pressure

i=53; % Stream number 1
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.95 0.025 0.002 0.0001 0.003]));  % Stream composition
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 1 1 1]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=0.3;       % Molar flow 
   S(ix(NC+2),ix(NC+2))=295;       % Temperature
   S(ix(NC+2),ix(NC+2))=500;       % Temperature
   S(ix(NC+3),ix(NC+3))=8;         % Pressure

i=54; % Stream number 1
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.95 0.025 0.002 0.0001 0.003]));  % Stream composition
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 1 1 1]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=0.5;       % Molar flow 
   S(ix(NC+2),ix(NC+2))=295;       % Temperature
   S(ix(NC+2),ix(NC+2))=500;       % Temperature
   S(ix(NC+3),ix(NC+3))=8;         % Pressure

i=55; % Stream number 1
   ix=IxStr(i);
   S(ix(1:NC),ix(1:NC))=sparse(diag([0.95 0.025 0.002 0.0001 0.003]));  % Stream composition
   S(ix(1:NC),ix(1:NC))=sparse(diag([1 1 1 1 1]));  % Stream composition
   S(ix(NC+1),ix(NC+1))=0.5;       % Molar flow 
   S(ix(NC+2),ix(NC+2))=323;       % Temperature
   S(ix(NC+2),ix(NC+2))=500;       % Temperature
   S(ix(NC+3),ix(NC+3))=12;        % Pressure

   
% Reactor variable scaling
for i=1:NCSTR
   ix=IxCSTR(i);
   S(ix,ix)=1;                      % Catalyst efficiency factor
end

% Heater variable scaling
for i=1:NHtr
   ix=IxHtr(i);
   S(ix,ix)=8000;                  % Duty
end


% Compressor variable scaling
for i=1:NCmp
   ix=IxCmp(i);
   S(ix(1),ix(1))=10000;             % Compressor work
   S(ix(2),ix(2))=  50;             % Compressor efficiency
   S(ix(3),ix(3))= 333;             % Compressor isentropic outlet temperature
end

% Heatexchanger variable scaling
for i=1:NHex
   ix=IxHex(i);
   S(ix(1),ix(1))=10000;            % Duty
end

% Condenser variables scaling
for i=1:NCon
   ix=IxCon(i);
   S(ix(1),ix(1))=10000;            % Duty
end

for i=1:NCon
   ix=IxCon(i);
   S(ix(1),ix(1))=10000;            % Duty
end

for i=1:NHex2
   ix=IxHex2(i);         
   S(ix(1),ix(1))=30000;            % Duty
   S(ix(2),ix(2))=240;              % Heat transfer coefficient
end

for i=1:NHex3
   ix=IxHex3(i);         
   S(ix(1),ix(1))=10000;            % Duty
   S(ix(2),ix(2))= 2;               % Molar flow 
   S(ix(3),ix(3))=288 ;             % Temperature
   S(ix(4),ix(4))=323;              % Temperature
   S(ix(5),ix(5))=100;              % Heat transfer coefficient
end

for i=1:NConstr
   ix=IxConstr(i);         
   S(ix(1),ix(1))= 100;              % RON
   S(ix(2),ix(2))=   8;              % H2/HC
   S(ix(3),ix(3))= 400;              % Feed Massflow
   S(ix(4),ix(4))= 200;              % Recyclagas flow
   S(ix(5),ix(5))= 100;              % Gas product flow
   S(ix(6),ix(6))=  80;              % Reformate product flow
   S(ix(7),ix(7))=   3;              % Reformate product flow
   
end