clear;clc;close all

set(0,'defaulttextinterpreter','Latex');


[x,T] = importData( 'SIM3Cooling_3.txt' ); 
xokr = x(5,:); %zadane HTC


% pre 0,5mm ... *T1*D4	nie je súčasťou CD
% pre 1mm ... *T2*D4		
% pre 2mm ... *T3*D15		nie je súčasťou CD
% pre 3mm ... *T4*D40		nie je súčasoťu CD
[SUMy,t] = importData( 'SIM3_ADAPT_T2_D4.txt' );
[ORG,t2] = importData( 'SIM3Cooling_3_EXPORT_T2_D4.txt' );
AF = importData( 'SIM3_ADAPT_T2filt_D4.txt' );
AFb = importData( 'SIM3_ADAPTBAD_T2filt_D4.txt' );
LOW = importData( 'SIM3_LOWPASS1HZ_T2filt_D4.txt' );
G30 = importData( 'SIM3_SLABYGAUSS30_T2filt_D4.txt' );
G500 = importData( 'SIM3_SILNYGAUSS500_T2filt_D4.txt' );

sumy = SUMy(3,:);
org = ORG(3,:);
af = AF(3,:);
afb = AFb(3,:);
low = LOW(3,:);
g30 = G30(3,:);
g500 = G500(3,:);

figure(1)
hold on

plot(t,afb,'color',[0.6, 0.2 0],'LineWidth',2)
plot(t,low,'m','LineWidth',2)
plot(t,g30,'g','LineWidth',2)
plot(t,g500,'y','LineWidth',2)
plot(t,af,'r','LineWidth',2)
plot(t2,org,'b','LineWidth',2)
plot(T,xokr,'k','LineWidth',2)
xlabel('$\tau [s]$');
ylabel('$HTC[Wm^{-2}K^{-1}]$');
ylh = get(gca,'ylabel');
gyl = get(ylh);                                                        
ylp = get(ylh, 'Position');
set(ylh, 'Rotation',0, 'Position',ylp, 'VerticalAlignment','middle', 'HorizontalAlignment','right')
set(gca,'FontSize',25)

legend('AFb','LOW','G30','G500','AF','originál','okrajová podmienka')

figure(2)
plot(t,SUMy(1,:),'LineWidth',2)
hold on
plot(t2,ORG(1,:),'k','LineWidth',2)

plot(t,LOW(1,:)','m','LineWidth',2)
plot(t,G30(1,:)','g','LineWidth',2)
plot(t,AFb(1,:)','color',[0.6, 0.2 0],'LineWidth',2)
plot(t,AF(1,:),'r','LineWidth',2)
plot(t,G500(1,:)','g','LineWidth',2)

xlabel('$\tau [s]$');
ylabel('$T_e[^{\circ}C]$');
ylh = get(gca,'ylabel');
gyl = get(ylh);                                                        
ylp = get(ylh, 'Position');
set(ylh, 'Rotation',0, 'Position',ylp, 'VerticalAlignment','middle', 'HorizontalAlignment','right')
set(gca,'FontSize',25)

legend('zašumené','originál','LOW','G30','AFb','AF','G500')

%% rozdiely

daf = af-org;
dafb = afb-org;
dg500 = g500-org;
dg30 = g30-org;
dlow = low-org;

rozdiely = [daf;dafb;dg500;dg30;dlow];
avgrozdiely = zeros(1,5);
avgrozdielyprechod = zeros(1,5);
rozptyly = zeros(1,5);
rozptylyprechod = zeros(1,5);

avgrozdielyprechodpravy = zeros(1,5);
rozptylyprechodpravy = zeros(1,5);
avgrozdielykoniecpravy = zeros(1,5);
rozptylykoniecpravy = zeros(1,5);
avgrozdielykonieclavy = zeros(1,5);
rozptylykonieclavy = zeros(1,5);

for i =1:5
   avgrozdiely(i) = sum(rozdiely(i,:))/length(rozdiely(i,:)); 
   avgrozdielykoniecpravy(i) = sum(rozdiely(i,15400:15600))/length(rozdiely(i,15400:15600));
   avgrozdielyprechodpravy(i) = sum(rozdiely(i,14480:14520))/length(rozdiely(i,14480:14520));
    avgrozdielyprechod(i) = sum(rozdiely(i,4480:4520))/length(rozdiely(i,4480:4520));
    avgrozdielykonieclavy(i) = sum(rozdiely(i,5490:5520))/length(rozdiely(i,5490:5520));
   
   rozptyly(i) = sqrt((1/length(rozdiely(i,:)))*sum((rozdiely(i,:)-avgrozdiely(i)).^2));
   rozptylykoniecpravy(i) = sqrt((1/length(rozdiely(i,15400:15600)))*sum((rozdiely(i,15400:15600)-avgrozdielykoniecpravy(i)).^2));
   rozptylyprechodpravy(i) = sqrt((1/length(rozdiely(i,14480:14520)))*sum((rozdiely(i,14480:14520)-avgrozdielyprechodpravy(i)).^2));
   rozptylyprechod(i) = sqrt((1/length(rozdiely(i,4480:4520)))*sum((rozdiely(i,4480:4520)-avgrozdielyprechod(i)).^2));
   rozptylykonieclavy(i) = sqrt((1/length(rozdiely(i,5490:5520)))*sum((rozdiely(i,5490:5520)-avgrozdielykonieclavy(i)).^2));
end