%script for reading and plotting the excel results

%results=xlsread('M:\Diplom\kaibel_test_results_working_prefrac_split.xls',
%'sheet1','b7:bf35');


%Extracting results from the excel worksheet:
rv=xlsread('M:\Diplom\kaibel_42stages_reflux12_rv.xls','sheet1','b7:b15');
tempprofilecolumn1=xlsread('M:\Diplom\kaibel_42stages_reflux12_rv.xls','sheet1','c7:ad15');
tempprofilecolumn2=xlsread('M:\Diplom\kaibel_42stages_reflux12_rv.xls','sheet1','ae7:ar15');
heatduty=xlsread('M:\Diplom\kaibel_42stages_reflux12_rv.xls','sheet1','as7:as15');
prodstreamD=xlsread('M:\Diplom\kaibel_42stages_reflux12_rv.xls','sheet1','at7:aw15');
prodstreamS1=xlsread('M:\Diplom\kaibel_42stages_reflux12_rv.xls','sheet1','ax7:ba15');
prodstreamS2=xlsread('M:\Diplom\kaibel_42stages_reflux12_rv.xls','sheet1','bb7:be15');
prodstreamB=xlsread('M:\Diplom\kaibel_42stages_reflux12_rv.xls','sheet1','bf7:bi15');
nstage=xlsread('M:\Diplom\kaibel_42stages_reflux12_rv.xls','sheet1','br7:br7');
prodstream_frac_sum=xlsread('M:\Diplom\kaibel_42stages_reflux12_rv.xls','sheet1','bu7:bu15');


%Defining which variables/runs/results to use:
enter=1;

if enter==1;
x=[2 5 8];
l=length(x);

rv_original = rv;
tempprofilecolumn1_original = tempprofilecolumn1;
tempprofilecolumn2_original = tempprofilecolumn2;
heatduty_original = heatduty;
prodstreamD_original = prodstreamD;
prodstreamS1_original = prodstreamS1;
prodstreamS2_original = prodstreamS2;
prodstreamB_original = prodstreamB;
prodstream_frac_sum_original = prodstream_frac_sum;


rv=[];
tempprofilecolumn1=[];
tempprofilecolumn2=[];
heatduty=[];
prodstreamD=[];
prodstreamS1=[];
prodstreamS2=[];
prodstreamB=[];
prodstream_frac_sum=[];


    for i=1:l;
    
        rv(i,:) = rv_original(x(i),:);
        tempprofilecolumn1(i,:) = tempprofilecolumn1_original(x(i),:);
        tempprofilecolumn2(i,:) = tempprofilecolumn2_original(x(i),:);
        heatduty(i,:) = heatduty_original(x(i),:);
        prodstreamD(i,:) = prodstreamD_original(x(i),:);
        prodstreamS1(i,:) = prodstreamS1_original(x(i),:);
        prodstreamS2(i,:) = prodstreamS2_original(x(i),:);
        prodstreamB(i,:) = prodstreamB_original(x(i),:);
        prodstream_frac_sum(i,:) = prodstream_frac_sum_original(x(i),:);
        
    end    
end

    
[runs,nstage1]=size(tempprofilecolumn1);
[runs,nstage2]=size(tempprofilecolumn2);

n1=(1:nstage1);
n2=(1:nstage2);

nsplittop=6;        %the plate where the TOP connect streams are connected (on column 1).
nsplittbottom=23;   %the plate where the BOTTOM connect streams are connected (on column 1).

n2stage_rel_to_1_temp=linspace(nsplittop+1,nsplittbottom-1,length(n2))+.6;
n2stage_rel_to_1=[(1:nsplittop) n2stage_rel_to_1_temp (nsplittbottom:nstage1)];

tempprofilecolumn2_1=[tempprofilecolumn1(:,1:nsplittop) tempprofilecolumn2 tempprofilecolumn1(:,nsplittbottom:nstage1)];



%figure

%plot(n1,tempprofilecolumn1,'b',n2stage_rel_to_1,tempprofilecolumn2_1,'y');
%hold on;

%figure
%plot(n1,tempprofilecolumn1(1,:),'--b',n2stage_rel_to_1,tempprofilecolumn2_1(1,:),'-b');xlabel('Stage number'),ylabel('Temperature [K]'),legend(['rv=',num2str(rv(1)),''])
%figure
%plot(n1,tempprofilecolumn1(2,:),'--b',n2stage_rel_to_1,tempprofilecolumn2_1(2,:),'-b');xlabel('Stage number'),ylabel('Temperature [K]'),legend(['rv=',num2str(rv(2)),''])
%figure
%plot(n1,tempprofilecolumn1(3,:),'--b',n2stage_rel_to_1,tempprofilecolumn2_1(3,:),'-b');xlabel('Stage number'),ylabel('Temperature [K]'),legend(['rv=',num2str(rv(3)),''])

%legend(['rv=',num2str(rv(1)),', temp profile column 1'],['rv=',num2str(rv(1)),', temp profile column 2'],['rv=',num2str(rv(2)),', temp profile column 1'],['rv=',num2str(rv(2)),', temp profile column 2']);
%legend(['rv=',num2str(rv(1)),', temp profile column 1'],['rv=',num2str(rv(1)),', temp profile column 2'],['rv=',num2str(rv(2)),', temp profile column 1'],['rv=',num2str(rv(2)),', temp profile column 2'],['rv=',num2str(rv(3)),', temp profile column 1'],['rv=',num2str(rv(3)),', temp profile column 2']);
%hold off;
%title('temp profile of rv',num2str(x(1:i)),'plot')

hold on

plot(n2stage_rel_to_1,tempprofilecolumn2_1(1,:),'-b',n2stage_rel_to_1,tempprofilecolumn2_1(2,:),'-.k',n2stage_rel_to_1,tempprofilecolumn2_1(3,:),'--r',n1,tempprofilecolumn1(1,:),'-b',n1,tempprofilecolumn1(2,:),'-.k',n1,tempprofilecolumn1(3,:),'--r')%,legend(['rv=',num2str(rv(1)),''])
%plot(n2stage_rel_to_1,tempprofilecolumn2_1(2,:),'-.k')%,legend(['rv=',num2str(rv(2)),''])
%plot(n2stage_rel_to_1,tempprofilecolumn2_1(3,:),'--r'),
legend(['rv=',num2str(rv(1)),''],['rv=',num2str(rv(2)),''],['rv=',num2str(rv(3)),''])
xlabel('Stage number'),ylabel('Temperature [K]')

hold off

