clear all
load reguleringkaskP1_1.txt;
start=2890;
stopp=7600;
reguleringkaskP1_1=reguleringkaskP1_1(start:stopp,:);
regulering=[reguleringkaskP1_1;reguleringkaskP1_1(4535:4680,:)];
regulering1=[regulering;reguleringkaskP1_1(4535:4680,:)];
regulering2=[regulering1;reguleringkaskP1_1(4535:4680,:)];
regulering3=[regulering2;reguleringkaskP1_1(4535:4680,:)];
regulering4=[regulering3;reguleringkaskP1_1(4535:4680,:)];
regulering5=[regulering4;reguleringkaskP1_1(4535:4680,:)];
regulering6=[regulering5;reguleringkaskP1_1(4535:4680,:)];




reguleringkaskP1_1=regulering6;
P1k=reguleringkaskP1_1(:,3);
zk=reguleringkaskP1_1(:,7);
t=cumsum(reguleringkaskP1_1(:,1));
tk=t/1000/60;
Wk=reguleringkaskP1_1(:,6);
Wsk=reguleringkaskP1_1(:,5);
P1k1=sgolayfilt(P1k,3,21);
Wk1=sgolayfilt(Wk,3,21);
Wsk1=sgolayfilt(Wsk,3,21);

figure(1)
subplot(3,1,1)
plot(tk,P1k,tk(1200:3150),0.110,'r.')
AXIS([0 10 0.06 0.16])
ylabel('P1 [barg]')
xlabel('time [min]')
legend('P1','Setpoint')
subplot(3,1,2)
plot(tk,Wk1)
ylabel('Massflow [kg/min]')
xlabel('time [min]')
AXIS([0 10 0 6])
subplot(3,1,3)
plot(tk,zk/100)
ylabel('Valve position')
xlabel('time [min]')
AXIS([0 10 0 1])

clear all
load reguleringkasP1;
t=t/60;
figure(2)
subplot(3,1,1)
plot(t,y_m1-1.013,t(3740:5765),0.11,'r.')
AXIS([0 10 0.06 0.16])
ylabel('P1 [barg]')
xlabel('time [min]')
legend('P1','Setpoint')
subplot(3,1,2)
plot(t,y_m2*60)
AXIS([0 10 0 6])
ylabel('Massflow [kg/min]')
xlabel('time [min]')
subplot(3,1,3)
plot(t,u)
AXIS([0 10 0 1])
ylabel('Valve position')
xlabel('time [min]')