clear all
load regulering4.txt
data=regulering4;

TS=data(:,1); %samler sammen data kolonnene
P1=data(:,4);
P2=data(:,5);
Q=data(:,6);%volumstrom vann
SP=data(:,7);
z=data(:,8);
tid=cumsum(TS); tid=tid/1000/60;%samler sammen tidsvektor
[ant_rader,ant_kol]=size(data);

tid_reg_paa=2;
index_reg_paa=find(abs(tid-tid_reg_paa)==min(abs(tid-tid_reg_paa)));
tid_reg_av=8;
index_reg_av=find(abs(tid-tid_reg_av)==min(abs(tid-tid_reg_av)));
SP=SP(index_reg_paa:index_reg_av);
tid_SP=tid(index_reg_paa:index_reg_av);


figure(2)
subplot(2,1,1)
plot(tid,P1)
hold on
plot(tid_SP,SP,'r-','linewidth',2)
hold off
legend('P_1 [barg]','SP [barg]',0)
ylabel('P_1 [barg]')
axis([0 10 0.06 0.16])

% ind=find(z<0);                          %for regulering2.txt
% z=[z(1:1184);z(1189:end)];              %
% tid=[tid(1:1184);tid(1189:end)];        %

subplot(2,1,2)
plot(tid,z)
ylabel('Ventilåpning %')
xlabel('tid [min]')
axis([0 10 0 80])

g=gcf;
set(g,'PaperUnits','centimeters','PaperType','A4')
opts = struct('FontMode','fixed','FontSize',9,'Width',15,'Color','rgb');
exportfig(g,'regulering30.eps',opts)