function varargout = Vysledky(varargin)
% VYSLEDKY M-file for Vysledky.fig
%      VYSLEDKY, by itself, creates a new VYSLEDKY or raises the existing
%      singleton*.
%
%      H = VYSLEDKY returns the handle to a new VYSLEDKY or the handle to
%      the existing singleton*.
%
%      VYSLEDKY('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in VYSLEDKY.M with the given input arguments.
%
%      VYSLEDKY('Property','Value',...) creates a new VYSLEDKY or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Vysledky_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Vysledky_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Vysledky

% Last Modified by GUIDE v2.5 03-May-2010 14:49:51

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Vysledky_OpeningFcn, ...
                   'gui_OutputFcn',  @Vysledky_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before Vysledky is made visible.
function Vysledky_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Vysledky (see VARARGIN)

% Choose default command line output for Vysledky
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Vysledky wait for user response (see UIRESUME)
% uiwait(handles.figure1);


global signal_original TPprum popup_sel_index QRS_pomoc prekroceni1 prekroceni2;
global sig_filt1 sig_filt2 sig_filt3;
global Delky Pohlavi prek_delk1 prek_delk2;
global kontrola;
kontrola = 0;

prekroceni1=0;
prekroceni2=0;

%----------plneni tabulky

columnHeaders = {'Metoda 1 [ms]','Metoda 2 [ms]','Prumer [ms]'};

set(handles.uitable1,'ColumnName',columnHeaders);
set(handles.uitable1,'data',Delky');
set(handles.uitable1, 'ColumnWidth', {98 98 98});


XX1 = 0;YY1 = 0;
XX2 = 0;YY2 = 0;

%--------------rozhodovaci pravidlo pro prekroceni mezi
switch Pohlavi;
    
    case 1

for i=1:1:length(Delky)
    if TPprum>=66 && TPprum<=100
        if Delky(1,i)>410
            XX1 = XX1 + 1;
            prekroceni1(XX1)=i;
        else
            YY1 = YY1 + 1;
        end
        
        if Delky(2,i)>410
            XX2 = XX2 + 1;
            prekroceni2(XX2)=i;
        else
            YY2 = YY2 + 1;
        end
    end
    
    if TPprum>=45 && TPprum<=65
        if Delky(1,i)>470
            XX1 = XX1 + 1;
            prekroceni1(XX1)=i;
        else
            YY1 = YY1 + 1;
        end
        
        if Delky(2,i)>410
            XX2 = XX2 + 1;
            prekroceni2(XX2)=i;
        else
            YY2 = YY2 + 1;
        end
    end
    
    if TPprum>100
        if Delky(1,i)>360
            XX1 = XX1 + 1;
            prekroceni1(XX1)=i
        else
            YY1 = YY1 + 1;
        end
        
        if Delky(2,i)>410
            XX2 = XX2 + 1;
            prekroceni2(XX2)=i
        else
            YY2 = YY2 + 1;
        end
    end
    
end

    case 2
    
for i=1:1:length(Delky)
    if TPprum>=66 && TPprum<=100
        if Delky(1,i)>430
            XX1 = XX1 + 1;
            prekroceni1(XX1)=i;
        else
            YY1 = YY1 + 1;
        end
        
        if Delky(2,i)>410
            XX2 = XX2 + 1;
            prekroceni2(XX2)=i;
        else
            YY2 = YY2 + 1;
        end
    end
    
    if TPprum>=45 && TPprum<=65
        if Delky(1,i)>480
            XX1 = XX1 + 1;
            prekroceni1(XX1)=i;
        else
            YY1 = YY1 + 1;
        end
        
        if Delky(2,i)>410
            XX2 = XX2 + 1;
            prekroceni2(XX2)=i;
        else
            YY2 = YY2 + 1;
        end
    end
    
    if TPprum>100
        if Delky(1,i)>370
            XX1 = XX1 + 1;
            prekroceni1(XX1)=i;
        else
            YY1 = YY1 + 1;
        end
        
        if Delky(2,i)>410
            XX2 = XX2 + 1;
            prekroceni2(XX2)=i;
        else
            YY2 = YY2 + 1;
        end
    end
    
    
end

end

%--------plneni tabulky metody 1 prekrocene meze
if prekroceni1==0
    
    columnHeaders = {'Cislo QRS','Metoda 1 [ms]'};
    set(handles.uitable2,'ColumnName',columnHeaders);
    set(handles.uitable2, 'ColumnWidth', {90 90});
    
else
    set(handles.uipanel7,'ForeGroundColor','red')
    prek_delk1=zeros(2,length(prekroceni1));
    prek_delk1(1,:)=prekroceni1;
    prek_delk1(2,:)=Delky(1,prekroceni1);
    
    columnHeaders = {'Cislo QRS','Metoda 1 [ms]'};
    set(handles.uitable2,'ColumnName',columnHeaders);
    set(handles.uitable2,'data',prek_delk1');  %-----druha tabulka-----
    set(handles.uitable2, 'ColumnWidth', {90 90});

end

%--------plneni tabulky metody 2 prekrocene meze
if prekroceni2==0
    
    columnHeaders = {'Cislo QRS','Metoda 2 [ms]'};
    set(handles.uitable3,'ColumnName',columnHeaders);
    set(handles.uitable3, 'ColumnWidth', {90 90});
    
else
    set(handles.uipanel7,'ForeGroundColor','red')
    prek_delk2=zeros(2,length(prekroceni2));
    prek_delk2(1,:)=prekroceni2;
    prek_delk2(2,:)=Delky(2,prekroceni2);
    
    columnHeaders = {'Cislo QRS','Metoda 2 [ms]'};
    set(handles.uitable3,'ColumnName',columnHeaders);
    set(handles.uitable3,'data',prek_delk2');  %-----druha tabulka-----
    set(handles.uitable3, 'ColumnWidth', {90 90});

end


axes(handles.axes1);x1 = [YY1 XX1];pie(x1,[1 0] );colormap winter
legend('Mez neprekrocena','Mez prekrocena','Location','BestOutside')

axes(handles.axes2);x2 = [YY2 XX2];pie(x2,[1 0])
legend('Mez neprekrocena','Mez prekrocena','Location','BestOutside')

clc

set(handles.text1,'string',length(Delky));
set(handles.text7,'string',TPprum);

set(handles.text15,'string',max(Delky(1,:)));
set(handles.text16,'string',max(Delky(2,:)));

set(handles.text17,'string',min(Delky(1,:)));
set(handles.text18,'string',min(Delky(2,:)));

set(handles.text19,'string',mean(Delky(1,:)));
set(handles.text20,'string',mean(Delky(2,:)));




%%
%--------------vykresleni----------------

QRS_vyb = str2num(get(handles.vyb_qrs,'string'));



konst=TPprum/80;
poz = [QRS_pomoc(QRS_vyb)-round(400/konst), QRS_pomoc(QRS_vyb)+round(600/konst)];


switch popup_sel_index
    case 1
        signal=sig_filt1;
        vyrez = signal(poz(1):poz(2));
        [Tkon1 Qzac1] = hranice_1(vyrez);
                
        vyrez = signal(poz(1):poz(2));
        [Tkon2 Qzac2] = hranice_2(vyrez);
        
    case 2
        signal=sig_filt2;
        vyrez = signal(poz(1):poz(2));
        [Tkon1 Qzac1] = hranice_1(vyrez);
        
        signal=sig_filt1;
        vyrez = signal(poz(1):poz(2));
        [Tkon2 Qzac2] = hranice_2(vyrez);
        
    case 3
        signal=sig_filt3;
        vyrez = signal(poz(1):poz(2));
        [Tkon1 Qzac1] = hranice_1(vyrez);
        
        signal=sig_filt1;
        vyrez = signal(poz(1):poz(2));
        [Tkon2 Qzac2] = hranice_2(vyrez);
        
    case 4
        QQ1=0; TT1=0;
        QQ = [0 0 0];TT = [0 0 0];
        
        signal=sig_filt1;
        vyrez = signal(poz(1):poz(2));
        [Tkon2 Qzac2] = hranice_2(vyrez);
        
        [Tkon1 Qzac1] = hranice_1(signal(poz(1):poz(2)));
        QQ(1)= Qzac1; TT(1)=Tkon1;
        
        [Tkon1 Qzac1] = hranice_1(sig_filt2(poz(1):poz(2)));
        QQ(2)= Qzac1; TT(2)=Tkon1;
        
        [Tkon1 Qzac1] = hranice_1(sig_filt3(poz(1):poz(2)));
        QQ(3)= Qzac1; TT(3)=Tkon1;
        
        
        Qzac1=median(QQ);Tkon1=median(TT);
        
end

hor=max(signal);dol=min(signal);

vykresleni = get(handles.popupmenu1, 'Value');

%------------vykresleni prvni metody---------------

axes(handles.axes3);
cla reset; %% maze auktualne nastaveny axes

zacQ1 = [Qzac1 Qzac1];konT1 = [Tkon1 Tkon1];osa = [hor dol]; %vykresleni hranice_1
plot(zacQ1,osa,'r');hold on;
plot(konT1,osa,'r');hold on;

[y x]=max(vyrez);

popis=strcat(num2str((round((Tkon1-Qzac1)*100))/100),' [ms]');
text(x+20,y,{popis});


ylabel('U [uV]');xlabel('t [ms]');



if vykresleni ==13
    for i=1:1:12
        plot(signal_original(i,poz(1):poz(2))-mean(signal_original(i,poz(1):poz(2))),'black');hold on;
    end
else      
    plot(signal_original(vykresleni,poz(1):poz(2))-mean(signal_original(vykresleni,poz(1):poz(2))),'black');hold on;
end

%---------vykresleni druhe metody---------------

axes(handles.axes4);
cla reset %% maze auktualne nastaveny axes

zacQ2 = [Qzac2 Qzac2];konT2 = [Tkon2 Tkon2];osa = [hor dol]; %vykresleni hranice_1
plot(zacQ2,osa,'r');hold on;
plot(konT2,osa,'r');hold on;


popis=strcat(num2str(Tkon2-Qzac2),' [ms]');
text(x+20,y,{popis});

ylabel('U [uV]');xlabel('t [ms]');

if vykresleni ==13
    for i=1:1:12
        plot(signal_original(i,poz(1):poz(2))-mean(signal_original(i,poz(1):poz(2))),'black');hold on;
    end
else      
    plot(signal_original(vykresleni,poz(1):poz(2))-mean(signal_original(vykresleni,poz(1):poz(2))),'black');hold on;
end





% --- Outputs from this function are returned to the command line.
function varargout = Vysledky_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;




% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



% --- Executes on button press in Zobrazeni1.
function Zobrazeni1_Callback(hObject, eventdata, handles)
% hObject    handle to Zobrazeni1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

global signal_original TPprum popup_sel_index QRS_pomoc;
global sig_filt1 sig_filt2 sig_filt3;

QRS_vyb = str2num(get(handles.vyb_qrs,'string'));


%--------osetreni editacniho pole

if isempty(QRS_vyb)
    msgboxText{1} =  'Zvolena hodnota neni cislo!'; 
    msgboxText{2} =  'Zadejte cislo od 1 do celkoveho poctu QRS.';
    msgbox(msgboxText,'Vstup neni cislo', 'error');
    return
elseif QRS_vyb < 1 || QRS_vyb > length(QRS_pomoc)
    msgboxText{1} =  'Zvolene cislo neodpovida zadnemu QRS!';
    msgboxText{2} =  'Zadejte cislo od 1 do celkoveho poctu QRS';
    msgbox(msgboxText,'Spatne cislo', 'error');
    return
elseif  round(QRS_vyb)-QRS_vyb ~= 0
    QRS_vyb = round(QRS_vyb);
    set(handles.vyb_qrs,'string',QRS_vyb)
end




%------------vykresleni nahledu 

konst=TPprum/80;
poz = [QRS_pomoc(QRS_vyb)-round(400/konst), QRS_pomoc(QRS_vyb)+round(600/konst)];


switch popup_sel_index
    case 1
        signal=sig_filt1;
        vyrez = signal(poz(1):poz(2));
        [Tkon1 Qzac1] = hranice_1(vyrez);
                
        vyrez = signal(poz(1):poz(2));
        [Tkon2 Qzac2] = hranice_2(vyrez);
        
    case 2
        signal=sig_filt2;
        vyrez = signal(poz(1):poz(2));
        [Tkon1 Qzac1] = hranice_1(vyrez);
        
        signal=sig_filt1;
        vyrez = signal(poz(1):poz(2));
        [Tkon2 Qzac2] = hranice_2(vyrez);
        
    case 3
        signal=sig_filt3;
        vyrez = signal(poz(1):poz(2));
        [Tkon1 Qzac1] = hranice_1(vyrez);
        
        signal=sig_filt1;
        vyrez = signal(poz(1):poz(2));
        [Tkon2 Qzac2] = hranice_2(vyrez);
        
    case 4
        
        QQ = [0 0 0];TT = [0 0 0];
        
        signal=sig_filt1;
        vyrez = signal(poz(1):poz(2));
        [Tkon2 Qzac2] = hranice_2(vyrez);
        
        [Tkon1 Qzac1] = hranice_1(signal(poz(1):poz(2)));
        QQ(1)= Qzac1; TT(1)=Tkon1;
        
        [Tkon1 Qzac1] = hranice_1(sig_filt2(poz(1):poz(2)));
        QQ(2)= Qzac1; TT(2)=Tkon1;
        
        [Tkon1 Qzac1] = hranice_1(sig_filt3(poz(1):poz(2)));
        QQ(3)= Qzac1; TT(3)=Tkon1;
        
        
        Qzac1=median(QQ);Tkon1=median(TT);
        
        
end

hor=max(signal);dol=min(signal);

vykresleni = get(handles.popupmenu1, 'Value');

%------------vykresleni prvni metody---------------

axes(handles.axes3);
cla reset; %% maze auktualne nastaveny axes

zacQ1 = [Qzac1 Qzac1];konT1 = [Tkon1 Tkon1];osa = [hor dol]; %vykresleni hranice_1
plot(zacQ1,osa,'r');hold on;
plot(konT1,osa,'r');hold on;


[y x]=max(vyrez);


popis=strcat(num2str((round((Tkon1-Qzac1)*100))/100),' [ms]');
text(x+20,y,{popis});

ylabel('U [uV]');xlabel('t [ms]');



if vykresleni ==13
    for i=1:1:12
        plot(signal_original(i,poz(1):poz(2))-mean(signal_original(i,poz(1):poz(2))),'black');hold on;
    end
else      
    plot(signal_original(vykresleni,poz(1):poz(2))-mean(signal_original(vykresleni,poz(1):poz(2))),'black');hold on;
end

%---------vykresleni druhe metody---------------

axes(handles.axes4);
cla reset %% maze auktualne nastaveny axes

zacQ2 = [Qzac2 Qzac2];konT2 = [Tkon2 Tkon2];osa = [hor dol]; %vykresleni hranice_1
plot(zacQ2,osa,'r');hold on;
plot(konT2,osa,'r');hold on;

popis=strcat(num2str(Tkon2-Qzac2),' [ms]');
text(x+20,y,{popis});

ylabel('U [uV]');xlabel('t [ms]');

if vykresleni ==13
    for i=1:1:12
        plot(signal_original(i,poz(1):poz(2))-mean(signal_original(i,poz(1):poz(2))),'black');hold on;
    end
else      
    plot(signal_original(vykresleni,poz(1):poz(2))-mean(signal_original(vykresleni,poz(1):poz(2))),'black');hold on;
end






function vyb_qrs_Callback(hObject, eventdata, handles)
% hObject    handle to vyb_qrs (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of vyb_qrs as text
%        str2double(get(hObject,'String')) returns contents of vyb_qrs as a double


% --- Executes during object creation, after setting all properties.
function vyb_qrs_CreateFcn(hObject, eventdata, handles)
% hObject    handle to vyb_qrs (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu1


% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



% --- Executes on button press in Ulozit.
function Ulozit_Callback(hObject, eventdata, handles)
% hObject    handle to Ulozit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.text4,'string','')

%----------ukladani do excelu
[filesave,pathsave] = uiputfile({'*.xlsx'},'Ulozeni vysledku');

if pathsave == 0 
    return
end

f = fullfile(pathsave, filesave);

global Delky FileName Pohlavi prek_delk1 prekroceni1 prek_delk2 prekroceni2;

switch Pohlavi
    case 1
        xlswrite(f,{'Pohlavi' 'Muz'},'sheet1','A2');
    case 2
        xlswrite(f,{'Pohlavi' 'Zena'},'sheet1','A2');
end

xlswrite(f,{'Nazev souboru' FileName},'sheet1','A1');

xlswrite(f,{'Tabulka namerenych delek QT intervalu'},'sheet1','A4');

rowHeader = {'Cislo QRS'; 'Metoda 1'; 'Metoda 2'; 'Prumer'};
xlswrite(f,rowHeader,'Sheet1','A5');
jednotky = {'[ms]'; '[ms]'; '[ms]'};
xlswrite(f,jednotky,'Sheet1','B6');
pocet = 1:1:length(Delky);
xlswrite(f,pocet,'Sheet1','C5');

xlswrite(f, Delky,'sheet1','C6');


xlswrite(f,{'Tabulka delek QT intervalu prekracujici meze'},'sheet1','A12');
xlswrite(f,{'Metoda 1'},'sheet1','A13');

if prekroceni1==0
    xlswrite(f,{'Meze nebyly prekroceny'},'sheet1','A14');
else
    rowHeader = {'Cislo QRS'; 'Delky'};
    xlswrite(f,rowHeader,'Sheet1','A14');
    xlswrite(f,{'[]'; '[ms]'},'Sheet1','B14');
    xlswrite(f,prek_delk1,'sheet1','C14');
end


xlswrite(f,{'Metoda 2'},'sheet1','A19');

if prekroceni2==0
    xlswrite(f,{'Meze nebyly prekroceny'},'sheet1','A20');
else
    rowHeader = {'Cislo QRS'; 'Delky'};
    xlswrite(f,rowHeader,'Sheet1','A20');
    xlswrite(f,{'[]'; '[ms]'},'Sheet1','B20');
    xlswrite(f,prek_delk2,'sheet1','C20');
end


set(handles.text4,'string','Data ulozena')


% --------------------------------------------------------------------
function Soubor_Callback(hObject, eventdata, handles)
% hObject    handle to Soubor (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function Napoveda1_Callback(hObject, eventdata, handles)
% hObject    handle to Napoveda1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
open('help.html')


% --------------------------------------------------------------------
function Ulozit_menu_Callback(hObject, eventdata, handles)
% hObject    handle to Ulozit_menu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.text4,'string','')

%----------ukladani do excelu

[filesave,pathsave] = uiputfile({'*.xlsx'},'Ulozeni vysledku');

if pathsave == 0 
    return
end

f = fullfile(pathsave, filesave);

global Delky FileName Pohlavi prek_delk1 prekroceni1 prek_delk2 prekroceni2;

switch Pohlavi
    case 1
        xlswrite(f,{'Pohlavi' 'Muz'},'sheet1','A2');
    case 2
        xlswrite(f,{'Pohlavi' 'Zena'},'sheet1','A2');
end

xlswrite(f,{'Nazev souboru' FileName},'sheet1','A1');

xlswrite(f,{'Tabulka namerenych delek QT intervalu'},'sheet1','A4');

rowHeader = {'Cislo QRS'; 'Metoda 1'; 'Metoda 2'; 'Prumer'};
xlswrite(f,rowHeader,'Sheet1','A5');
jednotky = {'[ms]'; '[ms]'; '[ms]'};
xlswrite(f,jednotky,'Sheet1','B6');
pocet = 1:1:length(Delky);
xlswrite(f,pocet,'Sheet1','C5');

xlswrite(f, Delky,'sheet1','C6');


xlswrite(f,{'Tabulka delek QT intervalu prekracujici meze'},'sheet1','A12');
xlswrite(f,{'Metoda 1'},'sheet1','A13');

if prekroceni1==0
    xlswrite(f,{'Meze nebyly prekroceny'},'sheet1','A14');
else
    rowHeader = {'Cislo QRS'; 'Delky'};
    xlswrite(f,rowHeader,'Sheet1','A14');
    xlswrite(f,{'[]'; '[ms]'},'Sheet1','B14');
    xlswrite(f,prek_delk1,'sheet1','C14');
end


xlswrite(f,{'Metoda 2'},'sheet1','A19');

if prekroceni2==0
    xlswrite(f,{'Meze nebyly prekroceny'},'sheet1','A20');
else
    rowHeader = {'Cislo QRS'; 'Delky'};
    xlswrite(f,rowHeader,'Sheet1','A20');
    xlswrite(f,{'[]'; '[ms]'},'Sheet1','B20');
    xlswrite(f,prek_delk2,'sheet1','C20');
end


set(handles.text4,'string','Data ulozena')


% --------------------------------------------------------------------
function Zavrit_Callback(hObject, eventdata, handles)
% hObject    handle to Zavrit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

global kontrola;kontrola=1;

close Vysledky;


% --------------------------------------------------------------------
function O_Programu_Callback(hObject, eventdata, handles)
% hObject    handle to O_Programu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% get the main_gui handle (access to the gui)
mainGUIhandle = O_programu;       
% get the data from the gui (all handles inside gui_main)
mainGUIdata  = guidata(mainGUIhandle);


% --------------------------------------------------------------------
function Napoveda_Callback(hObject, eventdata, handles)
% hObject    handle to Napoveda (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


