function varargout = Graf_App(varargin)
% GRAF_APP MATLAB code for Graf_App.fig
%      GRAF_APP, by itself, creates a new GRAF_APP or raises the existing
%      singleton*.
%
%      H = GRAF_APP returns the handle to a new GRAF_APP or the handle to
%      the existing singleton*.
%
%      GRAF_APP('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GRAF_APP.M with the given input arguments.
%
%      GRAF_APP('Property','Value',...) creates a new GRAF_APP or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Graf_App_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Graf_App_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 Graf_App

% Last Modified by GUIDE v2.5 18-Apr-2017 17:29:45

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Graf_App_OpeningFcn, ...
                   'gui_OutputFcn',  @Graf_App_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 Graf_App is made visible.
function Graf_App_OpeningFcn(hObject, eventdata, handles, varargin)

movegui(gcf,'center');
set(handles.btn_subor1,'enable','on');
set(handles.btn_subor2,'enable','off');
set(handles.btn_subor3,'enable','off');
set(handles.btn_subor4,'enable','off');
set(handles.btn_subor5,'enable','off');
set(handles.btn_subor6,'enable','off');
set(handles.btn_generovat,'enable','off');

for i = 1:6
    set(handles.(sprintf('text_nazov%d_d',i)),'string','N/A');
    set(handles.(sprintf('text_system%d_d',i)),'string','N/A');
    set(handles.(sprintf('text_alg%d_d',i)),'string','N/A');
    set(handles.(sprintf('text_snr%d_d',i)),'string','N/A');
    set(handles.(sprintf('text_data%d_d',i)),'string','N/A');
    set(handles.(sprintf('text_blok%d_d',i)),'string','N/A');
    set(handles.(sprintf('text_rate%d_d',i)),'string','N/A');
    set(handles.(sprintf('checkbox%d_iter1',i)),'value',0);
    set(handles.(sprintf('checkbox%d_iter2',i)),'value',0);
    set(handles.(sprintf('checkbox%d_iter4',i)),'value',0);
    set(handles.(sprintf('checkbox%d_iter6',i)),'value',0);
    set(handles.(sprintf('checkbox%d_iter8',i)),'value',0);
    set(handles.(sprintf('checkbox%d_iter10',i)),'value',0);
    set(handles.(sprintf('checkbox%d_iter1',i)),'enable','off');
    set(handles.(sprintf('checkbox%d_iter2',i)),'enable','off');
    set(handles.(sprintf('checkbox%d_iter4',i)),'enable','off');
    set(handles.(sprintf('checkbox%d_iter6',i)),'enable','off');
    set(handles.(sprintf('checkbox%d_iter8',i)),'enable','off');
    set(handles.(sprintf('checkbox%d_iter10',i)),'enable','off');
end

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = Graf_App_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 on button press in btn_subor1.
function btn_subor1_Callback(hObject, eventdata, handles)

set(handles.checkbox1_iter1,'enable','off');
set(handles.checkbox1_iter2,'enable','off');
set(handles.checkbox1_iter4,'enable','off');
set(handles.checkbox1_iter6,'enable','off');
set(handles.checkbox1_iter8,'enable','off');
set(handles.checkbox1_iter10,'enable','off');
set(handles.checkbox1_iter1,'value',0);
set(handles.checkbox1_iter2,'value',0);
set(handles.checkbox1_iter4,'value',0);
set(handles.checkbox1_iter6,'value',0);
set(handles.checkbox1_iter8,'value',0);
set(handles.checkbox1_iter10,'value',0);

[fname, path] = uigetfile('*.txt','Select txt file');
if fname == 0
    return;
else
    set(handles.text_nazov1_d,'string',fname);
    str = fullfile(path,fname);
    file = fopen(str,'r');
    a = textscan(file,'%s','delimiter','\n');

    if isequal(length(a{1,1}),8)
        system1 = a{1,1}{1,1};
        handles.system1 = system1;
        guidata(hObject,handles);
        
        alg1 = a{1,1}{2,1};
        handles.alg1 = alg1;
        guidata(hObject,handles);
        
        snr1 = str2num(a{1,1}{3,1});
        handles.snr1 = snr1;
        snr_str = sprintf('%0.2f:%0.2f:%0.2f',snr1(1),snr1(2),snr1(end));
        guidata(hObject,handles);
        
        data1 = a{1,1}{4,1};
        handles.data1 = data1;
        guidata(hObject,handles);
        
        blok1 = a{1,1}{5,1};
        handles.blok1 = blok1;
        guidata(hObject,handles);
        
        rate1 = a{1,1}{6,1};
        handles.rate1 = rate1;
        guidata(hObject,handles);
        
        deber1 = str2num(a{1,1}{7,1});
        handles.deber1 = deber1;
        guidata(hObject,handles);
        
        berU = str2num(a{1,1}{8,1});
        handles.berU = berU;
        guidata(hObject,handles);
        
        set(handles.text_system1_d,'string',system1);
        set(handles.text_alg1_d,'string',alg1);
        set(handles.text_snr1_d,'string',snr_str);
        set(handles.text_data1_d,'string',data1);
        set(handles.text_blok1_d,'string',blok1);
        set(handles.text_rate1_d,'string',rate1);
        
        [r,s] = size(deber1);
        switch r
            case 1
                set(handles.checkbox1_iter1,'enable','on');
            case 2
                set(handles.checkbox1_iter1,'enable','on');
                set(handles.checkbox1_iter2,'enable','on');
            case 4
                set(handles.checkbox1_iter1,'enable','on');
                set(handles.checkbox1_iter2,'enable','on');
                set(handles.checkbox1_iter4,'enable','on');
            case 6
                set(handles.checkbox1_iter1,'enable','on');
                set(handles.checkbox1_iter2,'enable','on');
                set(handles.checkbox1_iter4,'enable','on');
                set(handles.checkbox1_iter6,'enable','on');
            case 8
                set(handles.checkbox1_iter1,'enable','on');
                set(handles.checkbox1_iter2,'enable','on');
                set(handles.checkbox1_iter4,'enable','on');
                set(handles.checkbox1_iter6,'enable','on');
                set(handles.checkbox1_iter8,'enable','on');
            case 10
                set(handles.checkbox1_iter1,'enable','on');
                set(handles.checkbox1_iter2,'enable','on');
                set(handles.checkbox1_iter4,'enable','on');
                set(handles.checkbox1_iter6,'enable','on');
                set(handles.checkbox1_iter8,'enable','on');
                set(handles.checkbox1_iter10,'enable','on');
            otherwise
        end
        set(handles.btn_subor2,'enable','on');
        set(handles.btn_generovat,'enable','on');
    else
        warndlg('Nekompatibilny subor!!!','Error');
    end
end

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

% Hint: get(hObject,'Value') returns toggle state of checkbox1_iter1


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

% Hint: get(hObject,'Value') returns toggle state of checkbox1_iter2


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

% Hint: get(hObject,'Value') returns toggle state of checkbox1_iter4


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

% Hint: get(hObject,'Value') returns toggle state of checkbox1_iter8


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

% Hint: get(hObject,'Value') returns toggle state of checkbox1_iter10


% --- Executes on button press in btn_subor2.
function btn_subor2_Callback(hObject, eventdata, handles)

set(handles.checkbox2_iter1,'enable','off');
set(handles.checkbox2_iter2,'enable','off');
set(handles.checkbox2_iter4,'enable','off');
set(handles.checkbox2_iter6,'enable','off');
set(handles.checkbox2_iter8,'enable','off');
set(handles.checkbox2_iter10,'enable','off');
set(handles.checkbox2_iter1,'value',0);
set(handles.checkbox2_iter2,'value',0);
set(handles.checkbox2_iter4,'value',0);
set(handles.checkbox2_iter6,'value',0);
set(handles.checkbox2_iter8,'value',0);
set(handles.checkbox2_iter10,'value',0);

[fname, path] = uigetfile('*.txt','Select txt file');
if fname == 0
    return;
else
    set(handles.text_nazov2_d,'string',fname);
    str = fullfile(path,fname);
    file = fopen(str,'r');
    a = textscan(file,'%s','delimiter','\n');

    if isequal(length(a{1,1}),8)
        system2 = a{1,1}{1,1};
        handles.system2 = system2;
        guidata(hObject,handles);
        
        alg2 = a{1,1}{2,1};
        handles.alg2 = alg2;
        guidata(hObject,handles);
        
        snr2 = str2num(a{1,1}{3,1});
        handles.snr2 = snr2;
        snr_str = sprintf('%0.2f:%0.2f:%0.2f',snr2(1),snr2(2),snr2(end));
        guidata(hObject,handles);
        
        data2 = a{1,1}{4,1};
        handles.data2 = data2;
        guidata(hObject,handles);
        
        blok2 = a{1,1}{5,1};
        handles.blok2 = blok2;
        guidata(hObject,handles);
        
        rate2 = a{1,1}{6,1};
        handles.rate2 = rate2;
        guidata(hObject,handles);
        
        deber2 = str2num(a{1,1}{7,1});
        handles.deber2 = deber2;
        guidata(hObject,handles);
        
        set(handles.text_system2_d,'string',system2);
        set(handles.text_alg2_d,'string',alg2);
        set(handles.text_snr2_d,'string',snr_str);
        set(handles.text_data2_d,'string',data2);
        set(handles.text_blok2_d,'string',blok2);
        set(handles.text_rate2_d,'string',rate2);
        
        [r,s] = size(deber2);
        switch r
            case 1
                set(handles.checkbox2_iter1,'enable','on');
            case 2
                set(handles.checkbox2_iter1,'enable','on');
                set(handles.checkbox2_iter2,'enable','on');
            case 4
                set(handles.checkbox2_iter1,'enable','on');
                set(handles.checkbox2_iter2,'enable','on');
                set(handles.checkbox2_iter4,'enable','on');
            case 6
                set(handles.checkbox2_iter1,'enable','on');
                set(handles.checkbox2_iter2,'enable','on');
                set(handles.checkbox2_iter4,'enable','on');
                set(handles.checkbox2_iter6,'enable','on');
            case 8
                set(handles.checkbox2_iter1,'enable','on');
                set(handles.checkbox2_iter2,'enable','on');
                set(handles.checkbox2_iter4,'enable','on');
                set(handles.checkbox2_iter6,'enable','on');
                set(handles.checkbox2_iter8,'enable','on');
            case 10
                set(handles.checkbox2_iter1,'enable','on');
                set(handles.checkbox2_iter2,'enable','on');
                set(handles.checkbox2_iter4,'enable','on');
                set(handles.checkbox2_iter6,'enable','on');
                set(handles.checkbox2_iter8,'enable','on');
                set(handles.checkbox2_iter10,'enable','on');
            otherwise
        end
        set(handles.btn_subor3,'enable','on');
    else
        warndlg('Nekompatibilny subor!!!','Error');
    end
end

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

% Hint: get(hObject,'Value') returns toggle state of checkbox2_iter1


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

% Hint: get(hObject,'Value') returns toggle state of checkbox2_iter2


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

% Hint: get(hObject,'Value') returns toggle state of checkbox2_iter4


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

% Hint: get(hObject,'Value') returns toggle state of checkbox2_iter8


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

% Hint: get(hObject,'Value') returns toggle state of checkbox2_iter10


% --- Executes on button press in btn_subor3.
function btn_subor3_Callback(hObject, eventdata, handles)

set(handles.checkbox3_iter1,'enable','off');
set(handles.checkbox3_iter2,'enable','off');
set(handles.checkbox3_iter4,'enable','off');
set(handles.checkbox3_iter6,'enable','off');
set(handles.checkbox3_iter8,'enable','off');
set(handles.checkbox3_iter10,'enable','off');
set(handles.checkbox3_iter1,'value',0);
set(handles.checkbox3_iter2,'value',0);
set(handles.checkbox3_iter4,'value',0);
set(handles.checkbox3_iter6,'value',0);
set(handles.checkbox3_iter8,'value',0);
set(handles.checkbox3_iter10,'value',0);

[fname, path] = uigetfile('*.txt','Select txt file');
if fname == 0
    return;
else
    set(handles.text_nazov3_d,'string',fname);
    str = fullfile(path,fname);
    file = fopen(str,'r');
    a = textscan(file,'%s','delimiter','\n');

    if isequal(length(a{1,1}),8)
        system3 = a{1,1}{1,1};
        handles.system3 = system3;
        guidata(hObject,handles);
        
        alg3 = a{1,1}{2,1};
        handles.alg3 = alg3;
        guidata(hObject,handles);
        
        snr3 = str2num(a{1,1}{3,1});
        handles.snr3 = snr3;
        snr_str = sprintf('%0.2f:%0.2f:%0.2f',snr3(1),snr3(2),snr3(end));
        guidata(hObject,handles);
        
        data3 = a{1,1}{4,1};
        handles.data3 = data3;
        guidata(hObject,handles);
        
        blok3 = a{1,1}{5,1};
        handles.blok3 = blok3;
        guidata(hObject,handles);
        
        rate3 = a{1,1}{6,1};
        handles.rate3 = rate3;
        guidata(hObject,handles);
        
        deber3 = str2num(a{1,1}{7,1});
        handles.deber3 = deber3;
        guidata(hObject,handles);
        
        set(handles.text_system3_d,'string',system3);
        set(handles.text_alg3_d,'string',alg3);
        set(handles.text_snr3_d,'string',snr_str);
        set(handles.text_data3_d,'string',data3);
        set(handles.text_blok3_d,'string',blok3);
        set(handles.text_rate3_d,'string',rate3);
        
        [r,s] = size(deber3);
        switch r
            case 1
                set(handles.checkbox3_iter1,'enable','on');
            case 2
                set(handles.checkbox3_iter1,'enable','on');
                set(handles.checkbox3_iter2,'enable','on');
            case 4
                set(handles.checkbox3_iter1,'enable','on');
                set(handles.checkbox3_iter2,'enable','on');
                set(handles.checkbox3_iter4,'enable','on');
            case 6
                set(handles.checkbox3_iter1,'enable','on');
                set(handles.checkbox3_iter2,'enable','on');
                set(handles.checkbox3_iter4,'enable','on');
                set(handles.checkbox3_iter6,'enable','on');
            case 8
                set(handles.checkbox3_iter1,'enable','on');
                set(handles.checkbox3_iter2,'enable','on');
                set(handles.checkbox3_iter4,'enable','on');
                set(handles.checkbox3_iter6,'enable','on');
                set(handles.checkbox3_iter8,'enable','on');
            case 10
                set(handles.checkbox3_iter1,'enable','on');
                set(handles.checkbox3_iter2,'enable','on');
                set(handles.checkbox3_iter4,'enable','on');
                set(handles.checkbox3_iter6,'enable','on');
                set(handles.checkbox3_iter8,'enable','on');
                set(handles.checkbox3_iter10,'enable','on');
            otherwise
        end
        set(handles.btn_subor4,'enable','on');
    else
        warndlg('Nekompatibilny subor!!!','Error');
    end
end

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

% Hint: get(hObject,'Value') returns toggle state of checkbox3_iter1


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

% Hint: get(hObject,'Value') returns toggle state of checkbox3_iter2


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

% Hint: get(hObject,'Value') returns toggle state of checkbox3_iter4


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

% Hint: get(hObject,'Value') returns toggle state of checkbox3_iter8


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

% Hint: get(hObject,'Value') returns toggle state of checkbox3_iter10


% --- Executes on button press in btn_generovat.
function btn_generovat_Callback(hObject, eventdata, handles)
%%ZISTOVANIE KOLKO SUBOROV JE NAHRATYCH
%%AK JE NAHRATY IBA 1 SUBOR
if isequal(get(handles.text_system2_d,'string'),'N/A')
    
    if isfield(handles,'deber1_v')
        handles = rmfield(handles,'deber1_v');
    end
    if isfield(handles,'deber2_v')
        handles = rmfield(handles,'deber2_v');
    end
    if isfield(handles,'deber3_v')
        handles = rmfield(handles,'deber3_v');
    end
    if isfield(handles,'deber4_v')
        handles = rmfield(handles,'deber4_v');
    end
    if isfield(handles,'deber5_v')
        handles = rmfield(handles,'deber5_v');
    end
    if isfield(handles,'deber6_v')
        handles = rmfield(handles,'deber6_v');
    end
    
    %%ZISTOVANIE KTORE CHECKBOXY SU ZASKRTNUTE
    if isequal(get(handles.checkbox1_iter1,'value'),1)
        deber1_v(1,:) = handles.deber1(1,:);
    end
    
    for i = 2:2:10
        if isequal(get(handles.(sprintf('checkbox1_iter%d',i)),'value'),1)
            deber1_v(i,:) = handles.deber1(i,:);
        end
    end
    
    if exist('deber1_v','var') == 1
        handles.deber1_v = deber1_v;
        guidata(hObject,handles);
    end
    
    %%VYKRESLOVANIE GRAFOV
    iteracie = [1,2,4,6,8,10];
    line = '-';
    marker = ['o','+',' ','*',' ','x',' ','s',' ','d'];
    color = [1,0,0;0,1,0;0,0,1;1,0,1;1,1,0;0,1,1];
    a = figure;
    set(a,'position',[10,10,900,768]);
    plot = semilogy(handles.snr1,handles.berU);
    set(plot,'LineStyle',line,'Color',[0,0,0],'DisplayName','nekodovane');
    hold on;
        
    if isfield(handles,'deber1_v')&&~isempty(handles.deber1_v)
        [r1,s1] = size(handles.deber1_v);
        for i=1:r1
            if  (any(i==iteracie)&&(handles.deber1_v(i,1)~=0))
                plot = semilogy(handles.snr1,handles.deber1_v(i,:));
                [data_str,alg_str] = convert(str2num(handles.data1),1);
                set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(1,:)...
                    ,'DisplayName',sprintf('alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.alg1,data_str,handles.blok1,handles.rate1,i));
                hold on;
            end
        end
    end
    grid on;
    xlabel('Eb/N0 (dB)');
    ylabel('BER');
    title(sprintf('BER v závislosti na Eb/N0 pre %s',handles.system1),'FontSize', 14);
    legend('show','Location','northeast');
    
%%AK SU NAHRATE 2 SUBORY  
elseif isequal(get(handles.text_system3_d,'string'),'N/A')
    
    if isfield(handles,'deber1_v')
        handles = rmfield(handles,'deber1_v');
    end
    if isfield(handles,'deber2_v')
        handles = rmfield(handles,'deber2_v');
    end
    if isfield(handles,'deber3_v')
        handles = rmfield(handles,'deber3_v');
    end
    if isfield(handles,'deber4_v')
        handles = rmfield(handles,'deber4_v');
    end
    if isfield(handles,'deber5_v')
        handles = rmfield(handles,'deber5_v');
    end
    if isfield(handles,'deber6_v')
        handles = rmfield(handles,'deber6_v');
    end
    
    %%ZISTOVANIE KTORE CHECKBOXY SU ZASKRTNUTE
    if isequal(get(handles.checkbox1_iter1,'value'),1)
        deber1_v(1,:) = handles.deber1(1,:);
    end
    if isequal(get(handles.checkbox2_iter1,'value'),1)
        deber2_v(1,:) = handles.deber2(1,:);
    end
    
    for i = 2:2:10
        if isequal(get(handles.(sprintf('checkbox1_iter%d',i)),'value'),1)
            deber1_v(i,:) = handles.deber1(i,:);
        end
        if isequal(get(handles.(sprintf('checkbox2_iter%d',i)),'value'),1)
            deber2_v(i,:) = handles.deber2(i,:);
        end
    end
    
    if exist('deber1_v','var') == 1
        handles.deber1_v = deber1_v;
        guidata(hObject,handles);
    end
    if exist('deber2_v','var') == 1
        handles.deber2_v = deber2_v;
        guidata(hObject,handles);
    end
    
    %%VYKRESLOVANIE GRAFOV
    if isequal(handles.snr1(1),handles.snr2(1))&&isequal(handles.snr1(2),handles.snr2(2))&&isequal(handles.snr1(end),handles.snr2(end))
      
        iteracie = [1,2,4,6,8,10];
        line = '-';
        marker = ['o','+',' ','*',' ','x',' ','s',' ','d'];
        color = [1,0,0;0,1,0;0,0,1;1,0,1;1,1,0;0,1,1];
        a = figure;
        set(a,'position',[10,10,900,768]);
        plot = semilogy(handles.snr1,handles.berU);
        set(plot,'LineStyle',line,'Color',[0,0,0],'DisplayName','nekodovane');
        hold on;
        
        if isfield(handles,'deber1_v')&&~isempty(handles.deber1_v)
           [r1,s1] = size(handles.deber1_v);
           for i=1:r1
                if  (any(i==iteracie)&&(handles.deber1_v(i,1)~=0))
                    plot = semilogy(handles.snr1,handles.deber1_v(i,:));
                    [data_str,alg_str] = convert(str2num(handles.data1),1);
                    if isequal(handles.system1,handles.system2)
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(1,:)...
                            ,'DisplayName',sprintf('alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.alg1,data_str,handles.blok1,handles.rate1,i));
                        hold on;
                    else
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(1,:)...
                            ,'DisplayName',sprintf('sys=%s, alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.system1,handles.alg1,data_str,handles.blok1,handles.rate1,i));
                        hold on;
                    end
                end
            end
        end
        
       if isfield(handles,'deber2_v')
           [r2,s2] = size(handles.deber2_v);
           for i=1:r2
                if  (any(i==iteracie)&&(handles.deber2_v(i,1)~=0))
                    plot = semilogy(handles.snr2,handles.deber2_v(i,:));
                    [data_str,alg_str] = convert(str2num(handles.data2),1);
                    if isequal(handles.system1,handles.system2)
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(2,:)...
                            ,'DisplayName',sprintf('alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.alg2,data_str,handles.blok2,handles.rate2,i));
                        hold on;
                    else
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(2,:)...
                            ,'DisplayName',sprintf('sys=%s, alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.system2,handles.alg2,data_str,handles.blok2,handles.rate2,i));
                        hold on;
                    end;
                end
            end
        end
        grid on;
        xlabel('Eb/N0 (dB)');
        ylabel('BER');
        if isequal(handles.system1,handles.system2)
            title(sprintf('BER v závislosti na Eb/N0 pre %s',handles.system1),'FontSize', 14);
        else
            title(sprintf('BER v závislosti na Eb/N0.'),'FontSize', 14);
        end
        legend('show','Location','northeast');
    else
        warndlg('Minimalna, maximalna hodnota a krok snr musia byt rovnake!!!','Error');
    end

%%AK SU NAHRATE 3 SUBORY
elseif isequal(get(handles.text_system4_d,'string'),'N/A')
    if isfield(handles,'deber1_v')
        handles = rmfield(handles,'deber1_v');
    end
    if isfield(handles,'deber2_v')
        handles = rmfield(handles,'deber2_v');
    end
    if isfield(handles,'deber3_v')
        handles = rmfield(handles,'deber3_v');
    end
    if isfield(handles,'deber4_v')
        handles = rmfield(handles,'deber4_v');
    end
    if isfield(handles,'deber5_v')
        handles = rmfield(handles,'deber5_v');
    end
    if isfield(handles,'deber6_v')
        handles = rmfield(handles,'deber6_v');
    end
    
    %%ZISTOVANIE KTORE CHECK BOXY SU ZASKRTNUTE
    if isequal(get(handles.checkbox1_iter1,'value'),1)
        deber1_v(1,:) = handles.deber1(1,:);
    end
    if isequal(get(handles.checkbox2_iter1,'value'),1)
        deber2_v(1,:) = handles.deber2(1,:);
    end
    if isequal(get(handles.checkbox3_iter1,'value'),1)
        deber3_v(1,:) = handles.deber3(1,:);
    end
    
    for i = 2:2:10
        if isequal(get(handles.(sprintf('checkbox1_iter%d',i)),'value'),1)
            deber1_v(i,:) = handles.deber1(i,:);
        end
        if isequal(get(handles.(sprintf('checkbox2_iter%d',i)),'value'),1)
            deber2_v(i,:) = handles.deber2(i,:);
        end
        if isequal(get(handles.(sprintf('checkbox3_iter%d',i)),'value'),1)
            deber3_v(i,:) = handles.deber3(i,:);
        end
    end
    
    if exist('deber1_v','var') == 1
        handles.deber1_v = deber1_v;
        guidata(hObject,handles);
    end
    if exist('deber2_v','var') == 1
        handles.deber2_v = deber2_v;
        guidata(hObject,handles);
    end
    if exist('deber3_v','var') == 1
        handles.deber3_v = deber3_v;
        guidata(hObject,handles);
    end
    
    %%VYKRESLOVANIE GRAFOV
    if isequal(handles.snr1(1),handles.snr2(1),handles.snr3(1))&&isequal(handles.snr1(2),handles.snr2(2),handles.snr3(2))&&isequal(handles.snr1(end),handles.snr2(end),handles.snr3(end))
       
        iteracie = [1,2,4,6,8,10];
        line = '-';
        marker = ['o','+',' ','*',' ','x',' ','s',' ','d'];
        color = [1,0,0;0,1,0;0,0,1;1,0,1;1,1,0;0,1,1];
        a = figure;
        set(a,'position',[10,10,900,768]);
        plot = semilogy(handles.snr1,handles.berU);
        set(plot,'LineStyle',line,'Color',[0,0,0],'DisplayName','nekodovane');
        hold on;
        
        if isfield(handles,'deber1_v')&&~isempty(handles.deber1_v)
            [r1,s1] = size(handles.deber1_v);
            for i=1:r1
                if  (any(i==iteracie)&&(handles.deber1_v(i,1)~=0))
                    plot = semilogy(handles.snr1,handles.deber1_v(i,:));
                    [data_str,alg_str] = convert(str2num(handles.data1),1);
                    if isequal(handles.system1,handles.system2,handles.system3)
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(1,:)...
                            ,'DisplayName',sprintf('alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.alg1,data_str,handles.blok1,handles.rate1,i));
                        hold on;
                    else
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(1,:)...
                            ,'DisplayName',sprintf('sys=%s, alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.system1,handles.alg1,data_str,handles.blok1,handles.rate1,i));
                        hold on;
                    end
                end
            end
        end
        
        if isfield(handles,'deber2_v')
            [r2,s2] = size(handles.deber2_v);
            for i=1:r2
                if  (any(i==iteracie)&&(handles.deber2_v(i,1)~=0))
                    plot = semilogy(handles.snr2,handles.deber2_v(i,:));
                    [data_str,alg_str] = convert(str2num(handles.data2),1);
                    if isequal(handles.system1,handles.system2,handles.system3)
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(2,:)...
                            ,'DisplayName',sprintf('alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.alg2,data_str,handles.blok2,handles.rate2,i));
                        hold on;
                    else
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(2,:)...
                            ,'DisplayName',sprintf('sys=%s, alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.system2,handles.alg2,data_str,handles.blok2,handles.rate2,i));
                        hold on;
                    end;
                end
            end
        end
        
        if isfield(handles,'deber3_v')
            [r3,s3] = size(handles.deber3_v);
            for i=1:r3
                if  (any(i==iteracie)&&(handles.deber3_v(i,1)~=0))
                    plot = semilogy(handles.snr3,handles.deber3_v(i,:));
                    [data_str,alg_str] = convert(str2num(handles.data3),1);
                    if isequal(handles.system1,handles.system2,handles.system3)
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(3,:)...
                            ,'DisplayName',sprintf('alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.alg3,data_str,handles.blok3,handles.rate3,i));
                        hold on;
                    else
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(3,:)...
                            ,'DisplayName',sprintf('sys=%s, alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.system3,handles.alg3,data_str,handles.blok3,handles.rate3,i));
                        hold on;
                    end
                end
            end
        end
        grid on;
        xlabel('Eb/N0 (dB)');
        ylabel('BER');
        if isequal(handles.system1,handles.system2,handles.system3)
            title(sprintf('BER v závislosti na Eb/N0 pre %s',handles.system1),'FontSize', 14);
        else
            title(sprintf('BER v závislosti na Eb/N0'),'FontSize', 14);
        end
        legend('show','Location','northeast');
    else
        warndlg('Minimalna, maximalna hodnota a krok snr musia byt rovnake!!!','Error');
    end

%AK SU NAHRATE 4 SUBORY
elseif isequal(get(handles.text_system5_d,'string'),'N/A')
    if isfield(handles,'deber1_v')
        handles = rmfield(handles,'deber1_v');
    end
    if isfield(handles,'deber2_v')
        handles = rmfield(handles,'deber2_v');
    end
    if isfield(handles,'deber3_v')
        handles = rmfield(handles,'deber3_v');
    end
    if isfield(handles,'deber4_v')
        handles = rmfield(handles,'deber4_v');
    end
    if isfield(handles,'deber5_v')
        handles = rmfield(handles,'deber5_v');
    end
    if isfield(handles,'deber6_v')
        handles = rmfield(handles,'deber6_v');
    end
    
    %%ZISTOVANIE KTORE CHECK BOXY SU ZASKRTNUTE
    if isequal(get(handles.checkbox1_iter1,'value'),1)
        deber1_v(1,:) = handles.deber1(1,:);
    end
    if isequal(get(handles.checkbox2_iter1,'value'),1)
        deber2_v(1,:) = handles.deber2(1,:);
    end
    if isequal(get(handles.checkbox3_iter1,'value'),1)
        deber3_v(1,:) = handles.deber3(1,:);
    end
    if isequal(get(handles.checkbox4_iter1,'value'),1)
        deber4_v(1,:) = handles.deber4(1,:);
    end
    
    for i = 2:2:10
        if isequal(get(handles.(sprintf('checkbox1_iter%d',i)),'value'),1)
            deber1_v(i,:) = handles.deber1(i,:);
        end
        if isequal(get(handles.(sprintf('checkbox2_iter%d',i)),'value'),1)
            deber2_v(i,:) = handles.deber2(i,:);
        end
        if isequal(get(handles.(sprintf('checkbox3_iter%d',i)),'value'),1)
            deber3_v(i,:) = handles.deber3(i,:);
        end
        if isequal(get(handles.(sprintf('checkbox4_iter%d',i)),'value'),1)
            deber4_v(i,:) = handles.deber4(i,:);
        end
    end
    
    if exist('deber1_v','var') == 1
        handles.deber1_v = deber1_v;
        guidata(hObject,handles);
    end
    if exist('deber2_v','var') == 1
        handles.deber2_v = deber2_v;
        guidata(hObject,handles);
    end
    if exist('deber3_v','var') == 1
        handles.deber3_v = deber3_v;
        guidata(hObject,handles);
    end
    if exist('deber4_v','var') == 1
        handles.deber4_v = deber4_v;
        guidata(hObject,handles);
    end
    
    %%VYKRESLOVANIE GRAFOV
    if isequal(handles.snr1(1),handles.snr2(1),handles.snr3(1),handles.snr4(1))&&isequal(handles.snr1(2),handles.snr2(2),handles.snr3(2),handles.snr4(2))&&isequal(handles.snr1(end),handles.snr2(end),handles.snr3(end),handles.snr4(end))
       
        iteracie = [1,2,4,6,8,10];
        line = '-';
        marker = ['o','+',' ','*',' ','x',' ','s',' ','d'];
        color = [1,0,0;0,1,0;0,0,1;1,0,1;1,1,0;0,1,1];
        a = figure;
        set(a,'position',[10,10,900,768]);
        plot = semilogy(handles.snr1,handles.berU);
        set(plot,'LineStyle',line,'Color',[0,0,0],'DisplayName','nekodovane');
        hold on;
        
        if isfield(handles,'deber1_v')&&~isempty(handles.deber1_v)
            [r1,s1] = size(handles.deber1_v);
            for i=1:r1
                if  (any(i==iteracie)&&(handles.deber1_v(i,1)~=0))
                    plot = semilogy(handles.snr1,handles.deber1_v(i,:));
                    [data_str,alg_str] = convert(str2num(handles.data1),1);
                    if isequal(handles.system1,handles.system2,handles.system3,handles.system4)
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(1,:)...
                            ,'DisplayName',sprintf('alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.alg1,data_str,handles.blok1,handles.rate1,i));
                        hold on;
                    else
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(1,:)...
                            ,'DisplayName',sprintf('sys=%s, alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.system1,handles.alg1,data_str,handles.blok1,handles.rate1,i));
                        hold on;
                    end
                end
            end
        end
        
        if isfield(handles,'deber2_v')
            [r2,s2] = size(handles.deber2_v);
            for i=1:r2
                if  (any(i==iteracie)&&(handles.deber2_v(i,1)~=0))
                    plot = semilogy(handles.snr2,handles.deber2_v(i,:));
                    [data_str,alg_str] = convert(str2num(handles.data2),1);
                    if isequal(handles.system1,handles.system2,handles.system3,handles.system4)
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(2,:)...
                            ,'DisplayName',sprintf('alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.alg2,data_str,handles.blok2,handles.rate2,i));
                        hold on;
                    else
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(2,:)...
                            ,'DisplayName',sprintf('sys=%s, alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.system2,handles.alg2,data_str,handles.blok2,handles.rate2,i));
                        hold on;
                    end;
                end
            end
        end
        
        if isfield(handles,'deber3_v')
            [r3,s3] = size(handles.deber3_v);
            for i=1:r3
                if  (any(i==iteracie)&&(handles.deber3_v(i,1)~=0))
                    plot = semilogy(handles.snr3,handles.deber3_v(i,:));
                    [data_str,alg_str] = convert(str2num(handles.data3),1);
                    if isequal(handles.system1,handles.system2,handles.system3,handles.system4)
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(3,:)...
                            ,'DisplayName',sprintf('alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.alg3,data_str,handles.blok3,handles.rate3,i));
                        hold on;
                    else
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(3,:)...
                            ,'DisplayName',sprintf('sys=%s, alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.system3,handles.alg3,data_str,handles.blok3,handles.rate3,i));
                        hold on;
                    end
                end
            end
        end
        
        if isfield(handles,'deber4_v')
            [r4,s4] = size(handles.deber4_v);
            for i=1:r4
                if  (any(i==iteracie)&&(handles.deber4_v(i,1)~=0))
                    plot = semilogy(handles.snr4,handles.deber4_v(i,:));
                    [data_str,alg_str] = convert(str2num(handles.data4),1);
                    if isequal(handles.system1,handles.system2,handles.system3,handles.system4)
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(4,:)...
                            ,'DisplayName',sprintf('alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.alg4,data_str,handles.blok4,handles.rate4,i));
                        hold on;
                    else
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(4,:)...
                            ,'DisplayName',sprintf('sys=%s, alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.system4,handles.alg4,data_str,handles.blok4,handles.rate4,i));
                        hold on;
                    end;
                end
            end
        end
        grid on;
        xlabel('Eb/N0 (dB)');
        ylabel('BER');
        if isequal(handles.system1,handles.system2,handles.system3,handles.system4)
            title(sprintf('BER v závislosti na Eb/N0 pre %s',handles.system1),'FontSize', 14);
        else
            title(sprintf('BER v závislosti na Eb/N0'),'FontSize', 14);
        end
        legend('show','Location','northeast');
    else
        warndlg('Minimalna, maximalna hodnota a krok snr musia byt rovnake!!!','Error');
    end

%AK JE NAHRATYCH 5 SUBOROV
elseif isequal(get(handles.text_system6_d,'string'),'N/A')
    if isfield(handles,'deber1_v')
        handles = rmfield(handles,'deber1_v');
    end
    if isfield(handles,'deber2_v')
        handles = rmfield(handles,'deber2_v');
    end
    if isfield(handles,'deber3_v')
        handles = rmfield(handles,'deber3_v');
    end
    if isfield(handles,'deber4_v')
        handles = rmfield(handles,'deber4_v');
    end
    if isfield(handles,'deber5_v')
        handles = rmfield(handles,'deber5_v');
    end
    if isfield(handles,'deber6_v')
        handles = rmfield(handles,'deber6_v');
    end
    
    %%ZISTOVANIE KTORE CHECK BOXY SU ZASKRTNUTE
    if isequal(get(handles.checkbox1_iter1,'value'),1)
        deber1_v(1,:) = handles.deber1(1,:);
    end
    if isequal(get(handles.checkbox2_iter1,'value'),1)
        deber2_v(1,:) = handles.deber2(1,:);
    end
    if isequal(get(handles.checkbox3_iter1,'value'),1)
        deber3_v(1,:) = handles.deber3(1,:);
    end
    if isequal(get(handles.checkbox4_iter1,'value'),1)
        deber4_v(1,:) = handles.deber4(1,:);
    end
    if isequal(get(handles.checkbox5_iter1,'value'),1)
        deber5_v(1,:) = handles.deber5(1,:);
    end
    
    for i = 2:2:10
        if isequal(get(handles.(sprintf('checkbox1_iter%d',i)),'value'),1)
            deber1_v(i,:) = handles.deber1(i,:);
        end
        if isequal(get(handles.(sprintf('checkbox2_iter%d',i)),'value'),1)
            deber2_v(i,:) = handles.deber2(i,:);
        end
        if isequal(get(handles.(sprintf('checkbox3_iter%d',i)),'value'),1)
            deber3_v(i,:) = handles.deber3(i,:);
        end
        if isequal(get(handles.(sprintf('checkbox4_iter%d',i)),'value'),1)
            deber4_v(i,:) = handles.deber4(i,:);
        end
        if isequal(get(handles.(sprintf('checkbox5_iter%d',i)),'value'),1)
            deber5_v(i,:) = handles.deber5(i,:);
        end
    end
    
    if exist('deber1_v','var') == 1
        handles.deber1_v = deber1_v;
        guidata(hObject,handles);
    end
    if exist('deber2_v','var') == 1
        handles.deber2_v = deber2_v;
        guidata(hObject,handles);
    end
    if exist('deber3_v','var') == 1
        handles.deber3_v = deber3_v;
        guidata(hObject,handles);
    end
    if exist('deber4_v','var') == 1
        handles.deber4_v = deber4_v;
        guidata(hObject,handles);
    end
    if exist('deber5_v','var') == 1
        handles.deber5_v = deber5_v;
        guidata(hObject,handles);
    end
    
    %%VYKRESLOVANIE GRAFOV
    if isequal(handles.snr1(1),handles.snr2(1),handles.snr3(1),handles.snr4(1),handles.snr5(1))&&isequal(handles.snr1(2),handles.snr2(2),handles.snr3(2),handles.snr4(2),handles.snr5(2))&&isequal(handles.snr1(end),handles.snr2(end),handles.snr3(end),handles.snr4(end),handles.snr5(end))
       
        iteracie = [1,2,4,6,8,10];
        line = '-';
        marker = ['o','+',' ','*',' ','x',' ','s',' ','d'];
        color = [1,0,0;0,1,0;0,0,1;1,0,1;1,1,0;0,1,1];
        a = figure;
        set(a,'position',[10,10,900,768]);
        plot = semilogy(handles.snr1,handles.berU);
        set(plot,'LineStyle',line,'Color',[0,0,0],'DisplayName','nekodovane');
        hold on;
        
        if isfield(handles,'deber1_v')&&~isempty(handles.deber1_v)
            [r1,s1] = size(handles.deber1_v);
            for i=1:r1
                if  (any(i==iteracie)&&(handles.deber1_v(i,1)~=0))
                    plot = semilogy(handles.snr1,handles.deber1_v(i,:));
                    [data_str,alg_str] = convert(str2num(handles.data1),1);
                    if isequal(handles.system1,handles.system2,handles.system3,handles.system4,handles.system5)
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(1,:)...
                            ,'DisplayName',sprintf('alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.alg1,data_str,handles.blok1,handles.rate1,i));
                        hold on;
                    else
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(1,:)...
                            ,'DisplayName',sprintf('sys=%s, alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.system1,handles.alg1,data_str,handles.blok1,handles.rate1,i));
                        hold on;
                    end
                end
            end
        end
        
        if isfield(handles,'deber2_v')
            [r2,s2] = size(handles.deber2_v);
            for i=1:r2
                if  (any(i==iteracie)&&(handles.deber2_v(i,1)~=0))
                    plot = semilogy(handles.snr2,handles.deber2_v(i,:));
                    [data_str,alg_str] = convert(str2num(handles.data2),1);
                    if isequal(handles.system1,handles.system2,handles.system3,handles.system4,handles.system5)
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(2,:)...
                            ,'DisplayName',sprintf('alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.alg2,data_str,handles.blok2,handles.rate2,i));
                        hold on;
                    else
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(2,:)...
                            ,'DisplayName',sprintf('sys=%s, alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.system2,handles.alg2,data_str,handles.blok2,handles.rate2,i));
                        hold on;
                    end;
                end
            end
        end
        
        if isfield(handles,'deber3_v')
            [r3,s3] = size(handles.deber3_v);
            for i=1:r3
                if  (any(i==iteracie)&&(handles.deber3_v(i,1)~=0))
                    plot = semilogy(handles.snr3,handles.deber3_v(i,:));
                    [data_str,alg_str] = convert(str2num(handles.data3),1);
                    if isequal(handles.system1,handles.system2,handles.system3,handles.system4,handles.system5)
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(3,:)...
                            ,'DisplayName',sprintf('alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.alg3,data_str,handles.blok3,handles.rate3,i));
                        hold on;
                    else
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(3,:)...
                            ,'DisplayName',sprintf('sys=%s, alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.system3,handles.alg3,data_str,handles.blok3,handles.rate3,i));
                        hold on;
                    end
                end
            end
        end
        
        if isfield(handles,'deber4_v')
            [r4,s4] = size(handles.deber4_v);
            for i=1:r4
                if  (any(i==iteracie)&&(handles.deber4_v(i,1)~=0))
                    plot = semilogy(handles.snr4,handles.deber4_v(i,:));
                    [data_str,alg_str] = convert(str2num(handles.data4),1);
                    if isequal(handles.system1,handles.system2,handles.system3,handles.system4,handles.system5)
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(4,:)...
                            ,'DisplayName',sprintf('alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.alg4,data_str,handles.blok4,handles.rate4,i));
                        hold on;
                    else
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(4,:)...
                            ,'DisplayName',sprintf('sys=%s, alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.system4,handles.alg4,data_str,handles.blok4,handles.rate4,i));
                        hold on;
                    end
                end
            end
        end
        
        if isfield(handles,'deber5_v')
            [r5,s5] = size(handles.deber5_v);
            for i=1:r5
                if  (any(i==iteracie)&&(handles.deber5_v(i,1)~=0))
                    plot = semilogy(handles.snr5,handles.deber5_v(i,:));
                    [data_str,alg_str] = convert(str2num(handles.data5),1);
                    if isequal(handles.system1,handles.system2,handles.system3,handles.system4,handles.system5)
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(5,:)...
                            ,'DisplayName',sprintf('alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.alg5,data_str,handles.blok5,handles.rate5,i));
                        hold on;
                    else
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(5,:)...
                            ,'DisplayName',sprintf('sys=%s, alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.system5,handles.alg5,data_str,handles.blok5,handles.rate5,i));
                        hold on;
                    end
                end
            end
        end
        grid on;
        xlabel('Eb/N0 (dB)');
        ylabel('BER');
        if isequal(handles.system1,handles.system2,handles.system3,handles.system4,handles.system5)
            title(sprintf('BER v závislosti na Eb/N0 pre %s',handles.system1),'FontSize', 14);
        else
            title(sprintf('BER v závislosti na Eb/N0'),'FontSize', 14);
        end
        legend('show','Location','northeast');
    else
        warndlg('Minimalna, maximalna hodnota a krok snr musia byt rovnake!!!','Error');
    end
    
%AK JE NAHRATYCH 6 SUBOROV    
else
    if isfield(handles,'deber1_v')
        handles = rmfield(handles,'deber1_v');
    end
    if isfield(handles,'deber2_v')
        handles = rmfield(handles,'deber2_v');
    end
    if isfield(handles,'deber3_v')
        handles = rmfield(handles,'deber3_v');
    end
    if isfield(handles,'deber4_v')
        handles = rmfield(handles,'deber4_v');
    end
    if isfield(handles,'deber5_v')
        handles = rmfield(handles,'deber5_v');
    end
    if isfield(handles,'deber6_v')
        handles = rmfield(handles,'deber6_v');
    end
    
    %%ZISTOVANIE KTORE CHECK BOXY SU ZASKRTNUTE
    if isequal(get(handles.checkbox1_iter1,'value'),1)
        deber1_v(1,:) = handles.deber1(1,:);
    end
    if isequal(get(handles.checkbox2_iter1,'value'),1)
        deber2_v(1,:) = handles.deber2(1,:);
    end
    if isequal(get(handles.checkbox3_iter1,'value'),1)
        deber3_v(1,:) = handles.deber3(1,:);
    end
    if isequal(get(handles.checkbox4_iter1,'value'),1)
        deber4_v(1,:) = handles.deber4(1,:);
    end
    if isequal(get(handles.checkbox5_iter1,'value'),1)
        deber5_v(1,:) = handles.deber5(1,:);
    end
    if isequal(get(handles.checkbox6_iter1,'value'),1)
        deber6_v(1,:) = handles.deber6(1,:);
    end
    
    for i = 2:2:10
        if isequal(get(handles.(sprintf('checkbox1_iter%d',i)),'value'),1)
            deber1_v(i,:) = handles.deber1(i,:);
        end
        if isequal(get(handles.(sprintf('checkbox2_iter%d',i)),'value'),1)
            deber2_v(i,:) = handles.deber2(i,:);
        end
        if isequal(get(handles.(sprintf('checkbox3_iter%d',i)),'value'),1)
            deber3_v(i,:) = handles.deber3(i,:);
        end
        if isequal(get(handles.(sprintf('checkbox4_iter%d',i)),'value'),1)
            deber4_v(i,:) = handles.deber4(i,:);
        end
        if isequal(get(handles.(sprintf('checkbox5_iter%d',i)),'value'),1)
            deber5_v(i,:) = handles.deber5(i,:);
        end
        if isequal(get(handles.(sprintf('checkbox6_iter%d',i)),'value'),1)
            deber6_v(i,:) = handles.deber6(i,:);
        end
    end
    
    if exist('deber1_v','var') == 1
        handles.deber1_v = deber1_v;
        guidata(hObject,handles);
    end
    if exist('deber2_v','var') == 1
        handles.deber2_v = deber2_v;
        guidata(hObject,handles);
    end
    if exist('deber3_v','var') == 1
        handles.deber3_v = deber3_v;
        guidata(hObject,handles);
    end
    if exist('deber4_v','var') == 1
        handles.deber4_v = deber4_v;
        guidata(hObject,handles);
    end
    if exist('deber5_v','var') == 1
        handles.deber5_v = deber5_v;
        guidata(hObject,handles);
    end
    if exist('deber6_v','var') == 1
        handles.deber6_v = deber6_v;
        guidata(hObject,handles);
    end
    
    %%VYKRESLOVANIE GRAFOV
    if isequal(handles.snr1(1),handles.snr2(1),handles.snr3(1),handles.snr4(1),handles.snr5(1),handles.snr6(1))&&isequal(handles.snr1(2),handles.snr2(2),handles.snr3(2),handles.snr4(2),handles.snr5(2),handles.snr6(2))&&isequal(handles.snr1(end),handles.snr2(end),handles.snr3(end),handles.snr4(end),handles.snr5(end),handles.snr6(end))
       
        iteracie = [1,2,4,6,8,10];
        line = '-';
        marker = ['o','+',' ','*',' ','x',' ','s',' ','d'];
        color = [1,0,0;0,1,0;0,0,1;1,0,1;1,1,0;0,1,1];
        a = figure;
        set(a,'position',[10,10,900,768]);
        plot = semilogy(handles.snr1,handles.berU);
        set(plot,'LineStyle',line,'Color',[0,0,0],'DisplayName','nekodovane');
        hold on;
        
        if isfield(handles,'deber1_v')&&~isempty(handles.deber1_v)
            [r1,s1] = size(handles.deber1_v);
            for i=1:r1
                if  (any(i==iteracie)&&(handles.deber1_v(i,1)~=0))
                    plot = semilogy(handles.snr1,handles.deber1_v(i,:));
                    [data_str,alg_str] = convert(str2num(handles.data1),1);
                    if isequal(handles.system1,handles.system2,handles.system3,handles.system4,handles.system5,handles.system6)
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(1,:)...
                            ,'DisplayName',sprintf('alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.alg1,data_str,handles.blok1,handles.rate1,i));
                        hold on;
                    else
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(1,:)...
                            ,'DisplayName',sprintf('sys=%s, alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.system1,handles.alg1,data_str,handles.blok1,handles.rate1,i));
                        hold on;
                    end
                end
            end
        end
        
        if isfield(handles,'deber2_v')
            [r2,s2] = size(handles.deber2_v);
            for i=1:r2
                if  (any(i==iteracie)&&(handles.deber2_v(i,1)~=0))
                    plot = semilogy(handles.snr2,handles.deber2_v(i,:));
                    [data_str,alg_str] = convert(str2num(handles.data2),1);
                    if isequal(handles.system1,handles.system2,handles.system3,handles.system4,handles.system5,handles.system6)
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(2,:)...
                            ,'DisplayName',sprintf('alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.alg2,data_str,handles.blok2,handles.rate2,i));
                        hold on;
                    else
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(2,:)...
                            ,'DisplayName',sprintf('sys=%s, alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.system2,handles.alg2,data_str,handles.blok2,handles.rate2,i));
                        hold on;
                    end;
                end
            end
        end
        
        if isfield(handles,'deber3_v')
            [r3,s3] = size(handles.deber3_v);
            for i=1:r3
                if  (any(i==iteracie)&&(handles.deber3_v(i,1)~=0))
                    plot = semilogy(handles.snr3,handles.deber3_v(i,:));
                    [data_str,alg_str] = convert(str2num(handles.data3),1);
                    if isequal(handles.system1,handles.system2,handles.system3,handles.system4,handles.system5,handles.system6)
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(3,:)...
                            ,'DisplayName',sprintf('alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.alg3,data_str,handles.blok3,handles.rate3,i));
                        hold on;
                    else
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(3,:)...
                            ,'DisplayName',sprintf('sys=%s, alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.system3,handles.alg3,data_str,handles.blok3,handles.rate3,i));
                        hold on;
                    end
                end
            end
        end
        
        if isfield(handles,'deber4_v')
            [r4,s4] = size(handles.deber4_v);
            for i=1:r4
                if  (any(i==iteracie)&&(handles.deber4_v(i,1)~=0))
                    plot = semilogy(handles.snr4,handles.deber4_v(i,:));
                    [data_str,alg_str] = convert(str2num(handles.data4),1);
                    if isequal(handles.system1,handles.system2,handles.system3,handles.system4,handles.system5,handles.system6)
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(4,:)...
                            ,'DisplayName',sprintf('alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.alg4,data_str,handles.blok4,handles.rate4,i));
                        hold on;
                    else
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(4,:)...
                            ,'DisplayName',sprintf('sys=%s, alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.system4,handles.alg4,data_str,handles.blok4,handles.rate4,i));
                        hold on;
                    end
                end
            end
        end
        
        if isfield(handles,'deber5_v')
            [r5,s5] = size(handles.deber5_v);
            for i=1:r5
                if  (any(i==iteracie)&&(handles.deber5_v(i,1)~=0))
                    plot = semilogy(handles.snr5,handles.deber5_v(i,:));
                    [data_str,alg_str] = convert(str2num(handles.data5),1);
                    if isequal(handles.system1,handles.system2,handles.system3,handles.system4,handles.system5,handles.system6)
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(5,:)...
                            ,'DisplayName',sprintf('alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.alg5,data_str,handles.blok5,handles.rate5,i));
                        hold on;
                    else
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(5,:)...
                            ,'DisplayName',sprintf('sys=%s, alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.system5,handles.alg5,data_str,handles.blok5,handles.rate5,i));
                        hold on;
                    end
                end
            end
        end
        
        if isfield(handles,'deber6_v')
            [r6,s6] = size(handles.deber6_v);
            for i=1:r6
                if  (any(i==iteracie)&&(handles.deber6_v(i,1)~=0))
                    plot = semilogy(handles.snr6,handles.deber6_v(i,:));
                    [data_str,alg_str] = convert(str2num(handles.data6),1);
                    if isequal(handles.system1,handles.system2,handles.system3,handles.system4,handles.system5,handles.system6)
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(6,:)...
                            ,'DisplayName',sprintf('alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.alg6,data_str,handles.blok6,handles.rate6,i));
                        hold on;
                    else
                        set(plot,'LineStyle',line,'Marker',marker(i),'Color',color(6,:)...
                            ,'DisplayName',sprintf('sys=%s, alg=%s, data=%s, blok=%s, rate=%s, ite=%d',handles.system6,handles.alg6,data_str,handles.blok6,handles.rate6,i));
                        hold on;
                    end
                end
            end
        end
        grid on;
        xlabel('Eb/N0 (dB)');
        ylabel('BER');
        if isequal(handles.system1,handles.system2,handles.system3,handles.system4,handles.system5,handles.system6)
            title(sprintf('BER v závislosti na Eb/N0 pre %s',handles.system1),'FontSize', 14);
        else
            title(sprintf('BER v závislosti na Eb/N0'),'FontSize', 14);
        end
        legend('show','Location','northeast');
    else
        warndlg('Minimalna, maximalna hodnota a krok snr musia byt rovnake!!!','Error');
    end
end

% --- Executes when user attempts to close figure1.
function figure1_CloseRequestFcn(hObject, eventdata, handles)

Application;
delete(hObject);

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

% Hint: get(hObject,'Value') returns toggle state of checkbox1_iter6


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

% Hint: get(hObject,'Value') returns toggle state of checkbox2_iter6


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

% Hint: get(hObject,'Value') returns toggle state of checkbox3_iter6


% --- Executes on button press in btn_reset.
function btn_reset_Callback(hObject, eventdata, handles)

Graf_App_OpeningFcn(hObject, eventdata, handles);


% --- Executes on button press in btn_subor4.
function btn_subor4_Callback(hObject, eventdata, handles)

set(handles.checkbox4_iter1,'enable','off');
set(handles.checkbox4_iter2,'enable','off');
set(handles.checkbox4_iter4,'enable','off');
set(handles.checkbox4_iter6,'enable','off');
set(handles.checkbox4_iter8,'enable','off');
set(handles.checkbox4_iter10,'enable','off');
set(handles.checkbox4_iter1,'value',0);
set(handles.checkbox4_iter2,'value',0);
set(handles.checkbox4_iter4,'value',0);
set(handles.checkbox4_iter6,'value',0);
set(handles.checkbox4_iter8,'value',0);
set(handles.checkbox4_iter10,'value',0);

[fname, path] = uigetfile('*.txt','Select txt file');
if fname == 0
    return;
else
    set(handles.text_nazov4_d,'string',fname);
    str = fullfile(path,fname);
    file = fopen(str,'r');
    a = textscan(file,'%s','delimiter','\n');

    if isequal(length(a{1,1}),8)
        system4 = a{1,1}{1,1};
        handles.system4 = system4;
        guidata(hObject,handles);
        
        alg4 = a{1,1}{2,1};
        handles.alg4 = alg4;
        guidata(hObject,handles);
        
        snr4 = str2num(a{1,1}{3,1});
        handles.snr4 = snr4;
        snr_str = sprintf('%0.2f:%0.2f:%0.2f',snr4(1),snr4(2),snr4(end));
        guidata(hObject,handles);
        
        data4 = a{1,1}{4,1};
        handles.data4 = data4;
        guidata(hObject,handles);
        
        blok4 = a{1,1}{5,1};
        handles.blok4 = blok4;
        guidata(hObject,handles);
        
        rate4 = a{1,1}{6,1};
        handles.rate4 = rate4;
        guidata(hObject,handles);
        
        deber4 = str2num(a{1,1}{7,1});
        handles.deber4 = deber4;
        guidata(hObject,handles);
        
        berU = str2num(a{1,1}{8,1});
        handles.berU = berU;
        guidata(hObject,handles);
        
        set(handles.text_system4_d,'string',system4);
        set(handles.text_alg4_d,'string',alg4);
        set(handles.text_snr4_d,'string',snr_str);
        set(handles.text_data4_d,'string',data4);
        set(handles.text_blok4_d,'string',blok4);
        set(handles.text_rate4_d,'string',rate4);
        
        [r,s] = size(deber4);
        switch r
            case 1
                set(handles.checkbox4_iter1,'enable','on');
            case 2
                set(handles.checkbox4_iter1,'enable','on');
                set(handles.checkbox4_iter2,'enable','on');
            case 4
                set(handles.checkbox4_iter1,'enable','on');
                set(handles.checkbox4_iter2,'enable','on');
                set(handles.checkbox4_iter4,'enable','on');
            case 6
                set(handles.checkbox4_iter1,'enable','on');
                set(handles.checkbox4_iter2,'enable','on');
                set(handles.checkbox4_iter4,'enable','on');
                set(handles.checkbox4_iter6,'enable','on');
            case 8
                set(handles.checkbox4_iter1,'enable','on');
                set(handles.checkbox4_iter2,'enable','on');
                set(handles.checkbox4_iter4,'enable','on');
                set(handles.checkbox4_iter6,'enable','on');
                set(handles.checkbox4_iter8,'enable','on');
            case 10
                set(handles.checkbox4_iter1,'enable','on');
                set(handles.checkbox4_iter2,'enable','on');
                set(handles.checkbox4_iter4,'enable','on');
                set(handles.checkbox4_iter6,'enable','on');
                set(handles.checkbox4_iter8,'enable','on');
                set(handles.checkbox4_iter10,'enable','on');
            otherwise
        end
        set(handles.btn_subor5,'enable','on');
    else
        warndlg('Nekompatibilny subor!!!','Error');
    end
end

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

% Hint: get(hObject,'Value') returns toggle state of checkbox4_iter1


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

% Hint: get(hObject,'Value') returns toggle state of checkbox4_iter2


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

% Hint: get(hObject,'Value') returns toggle state of checkbox4_iter4


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

% Hint: get(hObject,'Value') returns toggle state of checkbox4_iter6


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

% Hint: get(hObject,'Value') returns toggle state of checkbox4_iter8


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

% Hint: get(hObject,'Value') returns toggle state of checkbox4_iter10


% --- Executes on button press in btn_subor5.
function btn_subor5_Callback(hObject, eventdata, handles)

set(handles.checkbox5_iter1,'enable','off');
set(handles.checkbox5_iter2,'enable','off');
set(handles.checkbox5_iter4,'enable','off');
set(handles.checkbox5_iter6,'enable','off');
set(handles.checkbox5_iter8,'enable','off');
set(handles.checkbox5_iter10,'enable','off');
set(handles.checkbox5_iter1,'value',0);
set(handles.checkbox5_iter2,'value',0);
set(handles.checkbox5_iter4,'value',0);
set(handles.checkbox5_iter6,'value',0);
set(handles.checkbox5_iter8,'value',0);
set(handles.checkbox5_iter10,'value',0);

[fname, path] = uigetfile('*.txt','Select txt file');
if fname == 0
    return;
else
    set(handles.text_nazov5_d,'string',fname);
    str = fullfile(path,fname);
    file = fopen(str,'r');
    a = textscan(file,'%s','delimiter','\n');

    if isequal(length(a{1,1}),8)
        system5 = a{1,1}{1,1};
        handles.system5 = system5;
        guidata(hObject,handles);
        
        alg5 = a{1,1}{2,1};
        handles.alg5 = alg5;
        guidata(hObject,handles);
        
        snr5 = str2num(a{1,1}{3,1});
        handles.snr5 = snr5;
        snr_str = sprintf('%0.2f:%0.2f:%0.2f',snr5(1),snr5(2),snr5(end));
        guidata(hObject,handles);
        
        data5 = a{1,1}{4,1};
        handles.data5 = data5;
        guidata(hObject,handles);
        
        blok5 = a{1,1}{5,1};
        handles.blok5 = blok5;
        guidata(hObject,handles);
        
        rate5 = a{1,1}{6,1};
        handles.rate5 = rate5;
        guidata(hObject,handles);
        
        deber5 = str2num(a{1,1}{7,1});
        handles.deber5 = deber5;
        guidata(hObject,handles);
        
        berU = str2num(a{1,1}{8,1});
        handles.berU = berU;
        guidata(hObject,handles);
        
        set(handles.text_system5_d,'string',system5);
        set(handles.text_alg5_d,'string',alg5);
        set(handles.text_snr5_d,'string',snr_str);
        set(handles.text_data5_d,'string',data5);
        set(handles.text_blok5_d,'string',blok5);
        set(handles.text_rate5_d,'string',rate5);
        
        [r,s] = size(deber5);
        switch r
            case 1
                set(handles.checkbox5_iter1,'enable','on');
            case 2
                set(handles.checkbox5_iter1,'enable','on');
                set(handles.checkbox5_iter2,'enable','on');
            case 4
                set(handles.checkbox5_iter1,'enable','on');
                set(handles.checkbox5_iter2,'enable','on');
                set(handles.checkbox5_iter4,'enable','on');
            case 6
                set(handles.checkbox5_iter1,'enable','on');
                set(handles.checkbox5_iter2,'enable','on');
                set(handles.checkbox5_iter4,'enable','on');
                set(handles.checkbox5_iter6,'enable','on');
            case 8
                set(handles.checkbox5_iter1,'enable','on');
                set(handles.checkbox5_iter2,'enable','on');
                set(handles.checkbox5_iter4,'enable','on');
                set(handles.checkbox5_iter6,'enable','on');
                set(handles.checkbox5_iter8,'enable','on');
            case 10
                set(handles.checkbox5_iter1,'enable','on');
                set(handles.checkbox5_iter2,'enable','on');
                set(handles.checkbox5_iter4,'enable','on');
                set(handles.checkbox5_iter6,'enable','on');
                set(handles.checkbox5_iter8,'enable','on');
                set(handles.checkbox5_iter10,'enable','on');
            otherwise
        end
        set(handles.btn_subor6,'enable','on');
    else
        warndlg('Nekompatibilny subor!!!','Error');
    end
end

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

% Hint: get(hObject,'Value') returns toggle state of checkbox5_iter1


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

% Hint: get(hObject,'Value') returns toggle state of checkbox5_iter2


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

% Hint: get(hObject,'Value') returns toggle state of checkbox5_iter4


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

% Hint: get(hObject,'Value') returns toggle state of checkbox5_iter6


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

% Hint: get(hObject,'Value') returns toggle state of checkbox5_iter8


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

% Hint: get(hObject,'Value') returns toggle state of checkbox5_iter10


% --- Executes on button press in btn_subor6.
function btn_subor6_Callback(hObject, eventdata, handles)

set(handles.checkbox6_iter1,'enable','off');
set(handles.checkbox6_iter2,'enable','off');
set(handles.checkbox6_iter4,'enable','off');
set(handles.checkbox6_iter6,'enable','off');
set(handles.checkbox6_iter8,'enable','off');
set(handles.checkbox6_iter10,'enable','off');
set(handles.checkbox6_iter1,'value',0);
set(handles.checkbox6_iter2,'value',0);
set(handles.checkbox6_iter4,'value',0);
set(handles.checkbox6_iter6,'value',0);
set(handles.checkbox6_iter8,'value',0);
set(handles.checkbox6_iter10,'value',0);

[fname, path] = uigetfile('*.txt','Select txt file');
if fname == 0
    return;
else
    set(handles.text_nazov6_d,'string',fname);
    str = fullfile(path,fname);
    file = fopen(str,'r');
    a = textscan(file,'%s','delimiter','\n');

    if isequal(length(a{1,1}),8)
        system6 = a{1,1}{1,1};
        handles.system6 = system6;
        guidata(hObject,handles);
        
        alg6 = a{1,1}{2,1};
        handles.alg6 = alg6;
        guidata(hObject,handles);
        
        snr6 = str2num(a{1,1}{3,1});
        handles.snr6 = snr6;
        snr_str = sprintf('%0.2f:%0.2f:%0.2f',snr6(1),snr6(2),snr6(end));
        guidata(hObject,handles);
        
        data6 = a{1,1}{4,1};
        handles.data6 = data6;
        guidata(hObject,handles);
        
        blok6 = a{1,1}{5,1};
        handles.blok6 = blok6;
        guidata(hObject,handles);
        
        rate6 = a{1,1}{6,1};
        handles.rate6 = rate6;
        guidata(hObject,handles);
        
        deber6 = str2num(a{1,1}{7,1});
        handles.deber6 = deber6;
        guidata(hObject,handles);
        
        berU = str2num(a{1,1}{8,1});
        handles.berU = berU;
        guidata(hObject,handles);
        
        set(handles.text_system6_d,'string',system6);
        set(handles.text_alg6_d,'string',alg6);
        set(handles.text_snr6_d,'string',snr_str);
        set(handles.text_data6_d,'string',data6);
        set(handles.text_blok6_d,'string',blok6);
        set(handles.text_rate6_d,'string',rate6);
        
        [r,s] = size(deber6);
        switch r
            case 1
                set(handles.checkbox6_iter1,'enable','on');
            case 2
                set(handles.checkbox6_iter1,'enable','on');
                set(handles.checkbox6_iter2,'enable','on');
            case 4
                set(handles.checkbox6_iter1,'enable','on');
                set(handles.checkbox6_iter2,'enable','on');
                set(handles.checkbox6_iter4,'enable','on');
            case 6
                set(handles.checkbox6_iter1,'enable','on');
                set(handles.checkbox6_iter2,'enable','on');
                set(handles.checkbox6_iter4,'enable','on');
                set(handles.checkbox6_iter6,'enable','on');
            case 8
                set(handles.checkbox6_iter1,'enable','on');
                set(handles.checkbox6_iter2,'enable','on');
                set(handles.checkbox6_iter4,'enable','on');
                set(handles.checkbox6_iter6,'enable','on');
                set(handles.checkbox6_iter8,'enable','on');
            case 10
                set(handles.checkbox6_iter1,'enable','on');
                set(handles.checkbox6_iter2,'enable','on');
                set(handles.checkbox6_iter4,'enable','on');
                set(handles.checkbox6_iter6,'enable','on');
                set(handles.checkbox6_iter8,'enable','on');
                set(handles.checkbox6_iter10,'enable','on');
            otherwise
        end
    else
        warndlg('Nekompatibilny subor!!!','Error');
    end
end

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

% Hint: get(hObject,'Value') returns toggle state of checkbox6_iter1


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

% Hint: get(hObject,'Value') returns toggle state of checkbox6_iter2


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

% Hint: get(hObject,'Value') returns toggle state of checkbox6_iter4


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

% Hint: get(hObject,'Value') returns toggle state of checkbox6_iter6


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

% Hint: get(hObject,'Value') returns toggle state of checkbox6_iter8


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

% Hint: get(hObject,'Value') returns toggle state of checkbox6_iter10
