% routine to close cascades, all except product flow, A Feed and C Feed
function A=cascaden(A)

% A is raw gain matrix
%close cascades
	for i=1:41
		kk(i,:)=A(i,:)-A(22,:)*A(i,11)/A(22,11);
	end
	kk(:,11)=A(:,11)/A(22,11);
	A=kk;
%condenser cw closed
	for i=1:41
		kk(i,:)=A(i,:)-A(21,:)*A(i,10)/A(21,10);
	end
	kk(:,10)=A(:,10)/A(21,10);
	A=kk;
%reactor CW closed
	for i=1:41
		kk(i,:)=A(i,:)-A(19,:)*A(i,9)/A(19,9);
	end
	kk(:,9)=A(:,9)/A(19,9);
	A=kk;
%steam closed
	for i=1:41
		kk(i,:)=A(i,:)-A(14,:)*A(i,7)/A(14,7);
	end
	kk(:,7)=A(:,7)/A(14,7);
	A=kk;
%Sep out closed
	for i=1:41
		kk(i,:)=A(i,:)-A(10,:)*A(i,6)/A(10,6);
	end
	kk(:,6)=A(:,6)/A(10,6);
	A=kk;
%purge closed

%	for i=1:41
%		kk(i,:)=A(i,:)-A(4,:)*A(i,4)/A(4,4);
%	end
%	kk(:,4)=A(:,4)/A(4,4);
%	A=kk;
%C feed closed

	for i=1:41
		kk(i,:)=A(i,:)-A(3,:)*A(i,2)/A(3,2);
	end
	kk(:,2)=A(:,2)/A(3,2);
	A=kk;

%E feed closed

	for i=1:41
		kk(i,:)=A(i,:)-A(2,:)*A(i,1)/A(2,1);
	end
	kk(:,1)=A(:,1)/A(2,1);
	A=kk;

%D Feed closed

%	for i=1:41
%		kk(i,:)=A(i,:)-A(1,:)*A(i,3)/A(1,3);
%	end
%	kk(:,3)=A(:,3)/A(1,3);
%	A=kk;
% A Feed Closed
% code below is for product
%	for i=1:41
%		kk(i,:)=A(i,:)-A(17,:)*A(i,8)/A(17,8);
%	end
%	kk(:,8)=A(:,8)/A(17,8);
%	A=kk;
