clc; close all;

%% Nacteni vstupnich dat

if not(exist('xdlkask'))
    clear all;
    [xdlkask,ynapt,xdlkask1,ynapt1,xdlkask2,ynapt2,xdlkask3,ynapt3,xdlkask4,ynapt4,xdlkask5,ynapt5,xdlkask6,ynapt6,xdlkask7,ynapt7] = importfile('EXCEL_grafy_napeti_SK_vnitrni.xlsx','List1');
end

if not(exist('xdelkask'))
    
    [xdelkask,ynapeti,xdelkask1,ynapeti1,xdelkask2,ynapeti2,xdelkask3,ynapeti3,xdelkask4,ynapeti4,xdelkask5,ynapeti5,xdelkask6,ynapeti6,xdelkask7,ynapeti7] = importfile2('EXCEL_grafy_napeti_SK_vnejsi.xlsx','List1');
end

if not(exist('xdelka1'))
    
    [xdelka1,yradposuv1,xdelka2,yradposuv2] = importfile3('EXCEL_grafy_posuvu.xlsx','List1');
end

%% Vykresleni

hold on
plot(xdlkask+0.043,ynapt,'r','LineWidth', 3, 'DisplayName', '0.7')
plot(xdlkask1,ynapt1,'color',[1 0.5 0])
plot(xdlkask2+0.043,ynapt2,'b')
plot(xdlkask3,ynapt3,'color',[0.5843 0.8157 0.9882])
plot(xdlkask4+0.043,ynapt4,'c')
plot(xdlkask5,ynapt5,'m')
plot(xdlkask6+0.043,ynapt6,'color',[0 0.6 0.2])
plot(xdlkask7,ynapt7,'g','LineWidth', 2)
grid on
legend('Osove nap MKP','Osove nap ANAL','Obvodove nap MKP','Obvodove nap ANAL','Normalove nap MKP','Normalove nap ANAL','Redukovane nap MKP','Redukovane nap ANAL')

figure

hold on
plot(xdelkask,ynapeti,'r','LineWidth', 3, 'DisplayName', '0.7')
plot(xdelkask1+0.087,ynapeti1,'color',[1 0.5 0])
plot(xdelkask2,ynapeti2,'b')
plot(xdelkask3+0.087,ynapeti3,'color',[0.5843 0.8157 0.9882])
plot(xdelkask4,ynapeti4,'c')
plot(xdelkask5+0.087,ynapeti5,'m')
plot(xdelkask6,ynapeti6,'color',[0 0.6 0.2])
plot(xdelkask7+0.087,ynapeti7,'g','LineWidth', 2)
grid on
legend('Osove nap MKP','Osove nap ANAL','Obvodove nap MKP','Obvodove nap ANAL','Normalove nap MKP','Normalove nap ANAL','Redukovane nap MKP','Redukovane nap ANAL')

%% Uprava

figure

pom = [0; xdelka2+0.1116]
pom2 = [1.9e-4 ;yradposuv2-0.0000132]
f1 = polyfit(pom,pom2,15)

hold on
plot(xdelka1,yradposuv1,'r')
plot(xdelka2+0.087,yradposuv2,'b')
%% plot(pom,polyval(f1,pom),'g')

grid on
legend('Posuv MKP','posuv ANALYT')
