clc; clear all; close all;

%extracting values from 42 stages:
column1_42raw   = xlsread('M:\Diplom\composition_42stages_12reflux_05rv.xls','sheet1','c7:f34');
column2_42raw   = xlsread('M:\Diplom\composition_42stages_12reflux_05rv.xls','sheet1','i7:l20');

%extracting values from 50 stages:
column1_50raw   = xlsread('M:\Diplom\composition_50stages_12reflux_05rv.xls','sheet1','c7:f39');
column2_50raw   = xlsread('M:\Diplom\composition_50stages_12reflux_05rv.xls','sheet1','i7:l23');

%extracting values from 59 stages:
column1_59raw   = xlsread('M:\Diplom\composition_59stages_12reflux_05rv.xls','sheet1','c7:f45');
column2_59raw   = xlsread('M:\Diplom\composition_59stages_12reflux_05rv.xls','sheet1','i7:l26');


%stage scaling

cs1_42 = 6;     cs1_50 = 7;     cs1_59 = 8;
cs2_42 = 23;    cs2_50 = 27;    cs2_59 = 32;

[col1_42,i]=size(column1_42raw);[col2_42,i]=size(column2_42raw);
[col1_50,i]=size(column1_50raw);[col2_50,i]=size(column2_50raw);
[col1_59,i]=size(column1_59raw);[col2_59,i]=size(column2_59raw);


%finding profiles:
prefrac42 = column1_42raw(cs1_42+1:cs2_42-1,:);
maincol42 = [column1_42raw(1:cs1_42,:)' column2_42raw(:,:)' column1_42raw(cs2_42:col1_42,:)']'; 

prefrac50 = column1_50raw(cs1_50+1:cs2_50-1,:);
maincol50 = [column1_50raw(1:cs1_50,:)' column2_50raw(:,:)' column1_50raw(cs2_50:col1_50,:)']'; 

prefrac59 = column1_59raw(cs1_59+1:cs2_59-1,:);
maincol59 = [column1_59raw(1:cs1_59,:)' column2_59raw(:,:)' column1_59raw(cs2_59:col1_59,:)']'; 

%main column scaling
nmain42 = (1:(cs1_42+col2_42+(col1_42-cs2_42+1)));mainsize42=length(nmain42);
nmain50 = (1:(cs1_50+col2_50+(col1_50-cs2_50+1)));mainsize50=length(nmain50);
nmain59 = (1:(cs1_59+col2_59+(col1_59-cs2_59+1)));mainsize59=length(nmain59);

%prefrac scaling
nprefrac42 = (1:(cs2_42-cs1_42-1));prefracsize42=length(nprefrac42);
nprefrac50 = (1:(cs2_50-cs1_50-1));prefracsize50=length(nprefrac50);
nprefrac59 = (1:(cs2_59-cs1_59-1));prefracsize59=length(nprefrac59);



%if scaling i==1
i=0;

if i==1;

    %42 stage scaling
    nmain42 = linspace(1,mainsize42,mainsize42);
    nprefrac42 = linspace(1,prefracsize42,prefracsize42);
    
    %50 stage scaling
    nmain50 = linspace(1,mainsize42,mainsize50);
    nprefrac50 = linspace(1,prefracsize42,prefracsize50);
    
    %59 stage scaling
    nmain59 = linspace(1,mainsize42,mainsize59);
    nprefrac59 = linspace(1,prefracsize42,prefracsize59);
    
    %plotting
    figure,plot(nmain42,maincol42(:,1),'-b',nmain50,maincol50(:,1),'-.k',nmain59,maincol59(:,1),'--r',nmain42,maincol42(:,2:4),'-b',nmain50,maincol50(:,2:4),'-.k',nmain59,maincol59(:,2:4),'--r')
    legend('42 stages','50stages','59 stages')
    xlabel('Stage number'),ylabel('Component molefraction'),axis([1 length(nmain42) 0 1])
    
    figure,plot(nprefrac42,prefrac42(:,1),'-b',nprefrac50,prefrac50(:,1),'-.k',nprefrac59,prefrac59(:,1),'--r',nprefrac42,prefrac42(:,2:4),'-b',nprefrac50,prefrac50(:,2:4),'-.k',nprefrac59,prefrac59(:,2:4),'--r')
    xlabel('Stage number'),ylabel('Component molefraction'),axis([1 length(prefrac42) 0 1])
    legend('42 stages','50stages','59 stages')

    
else




    %legend('42 stages','50 stages','59 stages')

    figure,plot(nmain42,maincol42(:,1),'-g',nmain42,maincol42(:,2),'-.k',nmain42,maincol42(:,3),'--r',nmain42,maincol42(:,4),':b'),xlabel('Stage number'), ylabel('Component molefraction'),axis([1 length(nmain42) 0 1])
    legend('Methanol','Ethanol','Propanol','Butanol')
    %figure,plot(nmain50,maincol50,'-b'),xlabel('Stage number'), ylabel('Component molefraction'),axis([1 length(nmain50) 0 1])
    %figure,plot(nmain59,maincol59,'-b'),xlabel('Stage number'), ylabel('Component molefraction'),axis([1 length(nmain59) 0 1])
    
    figure,plot(nprefrac42,prefrac42(:,1),'-g',nprefrac42,prefrac42(:,2),'-.k',nprefrac42,prefrac42(:,3),'--r',nprefrac42,prefrac42(:,4),':b'),xlabel('Stage number'), ylabel('Component molefraction'),axis([1 length(nprefrac42) 0 1])
    legend('Methanol','Ethanol','Propanol','Butanol')
    



end
