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

% Last Modified by GUIDE v2.5 07-Apr-2013 14:55:17

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Form_parameters_OpeningFcn, ...
                   'gui_OutputFcn',  @Form_parameters_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 Form_parameters is made visible.
function Form_parameters_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 Form_parameters (see VARARGIN)

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

handles.main_handles = varargin{1};
handles.par = handles.main_handles.par;
handles.main_handle = varargin{2};
% Update handles structure
guidata(hObject, handles);

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

reload(handles);

% --- Outputs from this function are returned to the command line.
function varargout = Form_parameters_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;



function edit_n_RNTI_Callback(hObject, eventdata, handles)
% hObject    handle to edit_n_RNTI (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 edit_n_RNTI as text
%        str2double(get(hObject,'String')) returns contents of edit_n_RNTI as a double


% --- Executes during object creation, after setting all properties.
function edit_n_RNTI_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_n_RNTI (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



function edit_N_CELL_Callback(hObject, eventdata, handles)
% hObject    handle to edit_N_CELL (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 edit_N_CELL as text
%        str2double(get(hObject,'String')) returns contents of edit_N_CELL as a double


% --- Executes during object creation, after setting all properties.
function edit_N_CELL_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_N_CELL (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 popupmenu_dmodType.
function popupmenu_dmodType_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu_dmodType (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

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


% --- Executes during object creation, after setting all properties.
function popupmenu_dmodType_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu_dmodType (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



function edit_dSchVec0_Callback(hObject, eventdata, handles)
% hObject    handle to edit_dSchVec0 (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 edit_dSchVec0 as text
%        str2double(get(hObject,'String')) returns contents of edit_dSchVec0 as a double


% --- Executes during object creation, after setting all properties.
function edit_dSchVec0_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_dSchVec0 (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



function edit_dSchVec1_Callback(hObject, eventdata, handles)
% hObject    handle to edit_dSchVec1 (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 edit_dSchVec1 as text
%        str2double(get(hObject,'String')) returns contents of edit_dSchVec1 as a double


% --- Executes during object creation, after setting all properties.
function edit_dSchVec1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_dSchVec1 (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



function edit_dSchVec2_Callback(hObject, eventdata, handles)
% hObject    handle to edit_dSchVec2 (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 edit_dSchVec2 as text
%        str2double(get(hObject,'String')) returns contents of edit_dSchVec2 as a double


% --- Executes during object creation, after setting all properties.
function edit_dSchVec2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_dSchVec2 (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



function edit_dSchVec3_Callback(hObject, eventdata, handles)
% hObject    handle to edit_dSchVec3 (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 edit_dSchVec3 as text
%        str2double(get(hObject,'String')) returns contents of edit_dSchVec3 as a double


% --- Executes during object creation, after setting all properties.
function edit_dSchVec3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_dSchVec3 (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



function edit_dSchVec4_Callback(hObject, eventdata, handles)
% hObject    handle to edit_dSchVec4 (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 edit_dSchVec4 as text
%        str2double(get(hObject,'String')) returns contents of edit_dSchVec4 as a double


% --- Executes during object creation, after setting all properties.
function edit_dSchVec4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_dSchVec4 (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



function edit_dSchVec5_Callback(hObject, eventdata, handles)
% hObject    handle to edit_dSchVec5 (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 edit_dSchVec5 as text
%        str2double(get(hObject,'String')) returns contents of edit_dSchVec5 as a double


% --- Executes during object creation, after setting all properties.
function edit_dSchVec5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_dSchVec5 (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 pushbutton_SAVE.
function pushbutton_SAVE_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_SAVE (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
par.vyrovKanal = get(handles.checkbox_vyrovKanal, 'Value');
[par.n_RNTI stat_RNTI] = str2num(get(handles.edit_n_RNTI, 'string'));
if(~stat_RNTI)
    set(handles.edit_n_RNTI,'Background', 'red');
    errordlg('Špatně zadané číslo. Zvolte 0 - 65536.', 'Hondota n_RNTI');
    return
else
    par.n_RNTI = round(par.n_RNTI);
    if(par.n_RNTI>=0 && par.n_RNTI<=65536)
        set(handles.edit_n_RNTI,'Background', 'white');
    else
        set(handles.edit_n_RNTI,'Background', 'red');
        errordlg('Špatně zadané číslo. Zvolte 0 - 65536.', 'Hondota n_RNTI');
        return
    end
end
[par.noise_rand_seed stat_noise_rand_seed] = str2num(get(handles.edit_noiseSeed, 'String'));
if(~stat_noise_rand_seed)
    set(handles.edit_noiseSeed,'Background', 'red');
    errordlg('Špatně zadané číslo. Zvolte 0 - 4294967295.', 'Hondota noise seed');
    return
else
    par.noise_rand_seed = round(par.noise_rand_seed(1));
    if(par.noise_rand_seed>=0 && par.noise_rand_seed<=4294967295)
        set(handles.edit_noiseSeed,'Background', 'white');
    else
        set(handles.edit_noiseSeed,'Background', 'red');
        errordlg('Špatně zadané číslo. Zvolte 0 - 4294967295.', 'Hondota noise seed');
        return
    end
end
[par.channel_rand_seed stat_channel_rand_seed] = str2num(get(handles.edit_channelSeed, 'String'));
if(~stat_channel_rand_seed)
    set(handles.edit_channelSeed,'Background', 'red');
    errordlg('Špatně zadané číslo. Zvolte 0 - 4294967295.', 'Hondota channel seed');
    return
else
    par.channel_rand_seed = round(par.channel_rand_seed(1));
    if(par.channel_rand_seed>=0 && par.channel_rand_seed<=4294967295)
        set(handles.edit_channelSeed,'Background', 'white');
    else
        set(handles.edit_channelSeed,'Background', 'red');
        errordlg('Špatně zadané číslo. Zvolte 0 - 4294967295.', 'Hondota channel seed');
        return
    end
end


[par.N_cell_ID stat_N_cell] = str2num(get(handles.edit_N_CELL, 'string'));
if(~stat_N_cell)
    set(handles.edit_N_CELL,'Background', 'red');
    errordlg('Špatně zadané číslo. Zvolte 0 - 503.', 'Hondota N_cell');
    return
else
    par.N_cell_ID = round(par.N_cell_ID);
    if(par.N_cell_ID>=0 && par.N_cell_ID<=503)
        set(handles.edit_N_CELL,'Background', 'white');
    else
        set(handles.edit_N_CELL,'Background', 'red');
        errordlg('Špatně zadané číslo. Zvolte 0 - 503.', 'Hondota N_cell');
        return
    end
end
[par.NIteraci stat_NIteraci] = str2num(get(handles.edit_NIteraci, 'string'));
if(~stat_NIteraci)
    set(handles.edit_NIteraci,'Background', 'red');
    errordlg('Špatně zadané číslo. Zvolte 1 - 64.', 'Počet iterací turbodekodéru');
    return
else
    par.NIteraci = round(par.NIteraci);
    if(par.NIteraci>=1 && par.NIteraci<=64)
        set(handles.edit_NIteraci,'Background', 'white');
    else
        set(handles.edit_NIteraci,'Background', 'red');
        errordlg('Špatně zadané číslo. Zvolte 1 - 64.', 'Počet iterací turbodekodéru');
        return
    end
end
switch (get(handles.popupmenu_dmodType, 'Value'))
    case 1
        par.dmodType = 'QPSK';
    case 2
        par.dmodType = '16QAM';
    case 3
        par.dmodType = '64QAM';
end
par.dSchVec = zeros(1,6);
% [CISN_krok err_CISN_krok] = str2num(get(handles.edit_Krok, 'string'));
[par.dSchVec1 stat_v1] = str2num(get(handles.edit_dSchVec0, 'string'));
[par.dSchVec2 stat_v2] = str2num(get(handles.edit_dSchVec1, 'string'));
[par.dSchVec3 stat_v3] = str2num(get(handles.edit_dSchVec2, 'string'));
[par.dSchVec4 stat_v4] = str2num(get(handles.edit_dSchVec3, 'string'));
[par.dSchVec5 stat_v5] = str2num(get(handles.edit_dSchVec4, 'string'));
[par.dSchVec6 stat_v6] = str2num(get(handles.edit_dSchVec5, 'string'));
if(~stat_v1)
    set(handles.edit_dSchVec0,'Background', 'red');
    errordlg('Špatně zadané číslo. Zvolte 1 pro použití zvoleného RB, 0 pro nepoužití.','Výběr RB');
    return
else
    set(handles.edit_dSchVec0,'Background', 'white');
    par.dSchVec(1) = abs(sign(par.dSchVec1));
end
if(~stat_v2)
    set(handles.edit_dSchVec1,'Background', 'red');
    errordlg('Špatně zadané číslo. Zvolte 1 pro použití zvoleného RB, 0 pro nepoužití.','Výběr RB');
    return
else
    set(handles.edit_dSchVec1,'Background', 'white');
    par.dSchVec(2) = abs(sign(par.dSchVec2));
end
if(~stat_v3)
    set(handles.edit_dSchVec2,'Background', 'red');
    errordlg('Špatně zadané číslo. Zvolte 1 pro použití zvoleného RB, 0 pro nepoužití.','Výběr RB');
    return
else
    set(handles.edit_dSchVec2,'Background', 'white');
    par.dSchVec(3) = abs(sign(par.dSchVec3));
end
if(~stat_v4)
    set(handles.edit_dSchVec3,'Background', 'red');
    errordlg('Špatně zadané číslo. Zvolte 1 pro použití zvoleného RB, 0 pro nepoužití.','Výběr RB');
    return
else
    set(handles.edit_dSchVec3,'Background', 'white');
    par.dSchVec(4) = abs(sign(par.dSchVec4));
end
if(~stat_v5)
    set(handles.edit_dSchVec4,'Background', 'red');
    errordlg('Špatně zadané číslo. Zvolte 1 pro použití zvoleného RB, 0 pro nepoužití.','Výběr RB');
    return
else
    set(handles.edit_dSchVec4,'Background', 'white');
    par.dSchVec(5) = abs(sign(par.dSchVec5));
end
if(~stat_v6)
    set(handles.edit_dSchVec5,'Background', 'red');
    errordlg('Špatně zadané číslo. Zvolte 1 pro použití zvoleného RB, 0 pro nepoužití.','Výběr RB');
    return
else
    set(handles.edit_dSchVec5,'Background', 'white');
    par.dSchVec(6) = abs(sign(par.dSchVec6));
end
if(sum(par.dSchVec) < 1)
    set(handles.edit_dSchVec0,'Background', 'red');
    set(handles.edit_dSchVec1,'Background', 'red');
    set(handles.edit_dSchVec2,'Background', 'red');
    set(handles.edit_dSchVec3,'Background', 'red');
    set(handles.edit_dSchVec4,'Background', 'red');
    set(handles.edit_dSchVec5,'Background', 'red');
    errordlg('Je třeba zvolit alespoň jeden RB pro mapování uživatelských dat.','Výběr RB');
    return
else
    set(handles.edit_dSchVec0,'Background', 'white');
    set(handles.edit_dSchVec1,'Background', 'white');
    set(handles.edit_dSchVec2,'Background', 'white');
    set(handles.edit_dSchVec3,'Background', 'white');
    set(handles.edit_dSchVec4,'Background', 'white');
    set(handles.edit_dSchVec5,'Background', 'white');
end
par.q = 0;
par.dc_init = par.n_RNTI*2^14 + par.q*2^13 + floor(1/2)*2^9 + par.N_cell_ID;
             
% Modulace
switch par.dmodType
    case 'BPSK'
        par.dmodBit = 1;
    case 'QPSK'
        par.dmodBit = 2;
    case '16QAM'
        par.dmodBit = 4;
    case '64QAM'
        par.dmodBit = 6;
end
par.SchMAX = 6; % Maximální počet přenesených RB = odpovídá BW 1.4MHz

switch (get(handles.popup_umodType, 'Value'))
    case 1
        par.umodType = 'QPSK';
    case 2
        par.umodType = '16QAM';
    case 3
        par.umodType = '64QAM';
end
par.uSchVecp = [2 3 1];
par.uSchVecp(1) = get(handles.edit_uSchVecp1, 'Value')-1;
par.uSchVecp(2) = get(handles.edit_uSchVecp2, 'Value');
par.uSchVecp(3) = 6 - (par.uSchVecp(1) + par.uSchVecp(2));
if(par.uSchVecp(3) < 0)
    warning('Špatné nastavení mapování uživatelských dat na uplinku. Bylo nastaveno výchozí nastavení.');
    par.uSchVecp = [2 3 1];
end
par.uSchVec = [zeros(1,par.uSchVecp(1)) ...
               ones(1,par.uSchVecp(2)) ...
               zeros(1,par.uSchVecp(3))];
set(handles.edit_uSchVec0, 'String', par.uSchVec(1));
set(handles.edit_uSchVec1, 'String', par.uSchVec(2));
set(handles.edit_uSchVec2, 'String', par.uSchVec(3));
set(handles.edit_uSchVec3, 'String', par.uSchVec(4));
set(handles.edit_uSchVec4, 'String', par.uSchVec(5));
set(handles.edit_uSchVec5, 'String', par.uSchVec(6));

% Scrambling
% c_init = n_RNTI*2^14 + floor(n_S/2)*2^9 + N_cell_ID;
%          12345*2^14   + 1*2^9            + 102     =1858683492;
% n_RNTI = 12345; par.N_cell_ID = 102; stejné jako downlink
par.uc_init = par.n_RNTI*2^14 + floor(1/2)*2^9 + par.N_cell_ID;
% Modulace
switch par.umodType
    case 'BPSK'
        par.umodBit = 1;
    case 'QPSK'
        par.umodBit = 2;
    case '16QAM'
        par.umodBit = 4;
    case '64QAM'
        par.umodBit = 6;
end

save('parameters.mat', 'par');
% Update handles structure
handles.par = par;
handles.main_handles.par = par;
guidata(hObject, handles);

guidata(handles.main_handle,handles.main_handles) 

reload(handles);
helpdlg('Nastavení bylo uloženo.', 'Uložení nastavení');

% --- Executes on button press in pushbutton_Default.
function pushbutton_Default_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_Default (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.par = init_parameters('parameters');
handles.main_handles.par = handles.par;
guidata(hObject, handles);

guidata(handles.main_handle,handles.main_handles) 
reload(handles);
    set(handles.edit_n_RNTI,'Background', 'white');
    set(handles.edit_noiseSeed,'Background', 'white');
    set(handles.edit_NIteraci,'Background', 'white');
    set(handles.edit_N_CELL,'Background', 'white');
    set(handles.edit_channelSeed,'Background', 'white');
    set(handles.edit_dSchVec0,'Background', 'white');
    set(handles.edit_dSchVec1,'Background', 'white');
    set(handles.edit_dSchVec2,'Background', 'white');
    set(handles.edit_dSchVec3,'Background', 'white');
    set(handles.edit_dSchVec4,'Background', 'white');
    set(handles.edit_dSchVec5,'Background', 'white');
helpdlg('Bylo obnoveno výchozí nastavení.', 'Výchozí nastavení');


function reload(handles)
%% Ověření existence souboru s nastavením
if( min(exist('parameters.mat')) == 0)
    par = init_parameters('parameters');
else
    par = handles.par;
    % load('parameters.mat');
end
set(handles.checkbox_vyrovKanal,'Value', par.vyrovKanal);
set(handles.edit_n_RNTI, 'String', par.n_RNTI);
set(handles.edit_N_CELL, 'String', par.N_cell_ID);
set(handles.edit_noiseSeed, 'String', sprintf('%13d',par.noise_rand_seed));
set(handles.edit_channelSeed, 'String', sprintf('%13d',par.channel_rand_seed));
set(handles.edit_NIteraci, 'String', par.NIteraci);

switch (par.dmodType)
    case 'QPSK'
        set(handles.popupmenu_dmodType, 'Value', 1);
    case '16QAM'
        set(handles.popupmenu_dmodType, 'Value', 2);
    case '64QAM'
        set(handles.popupmenu_dmodType, 'Value', 3);
end
set(handles.edit_dSchVec0, 'String', par.dSchVec(1));
set(handles.edit_dSchVec1, 'String', par.dSchVec(2));
set(handles.edit_dSchVec2, 'String', par.dSchVec(3));
set(handles.edit_dSchVec3, 'String', par.dSchVec(4));
set(handles.edit_dSchVec4, 'String', par.dSchVec(5));
set(handles.edit_dSchVec5, 'String', par.dSchVec(6));

switch (par.umodType)
    case 'QPSK'
        set(handles.popup_umodType, 'Value', 1);
    case '16QAM'
        set(handles.popup_umodType, 'Value', 2);
    case '64QAM'
        set(handles.popup_umodType, 'Value', 3);
end
set(handles.edit_uSchVecp1, 'Value', par.uSchVecp(1)+1);
uSchVecp1 = get(handles.edit_uSchVecp1,'Value');
a = cell(7-uSchVecp1,1);for i = 1:7-uSchVecp1, a{i} = sprintf('%d', i);end
set(handles.edit_uSchVecp2, 'String', a);
set(handles.edit_uSchVecp2, 'Value', par.uSchVecp(2));

set(handles.edit_uSchVec0, 'String', par.uSchVec(1));
set(handles.edit_uSchVec1, 'String', par.uSchVec(2));
set(handles.edit_uSchVec2, 'String', par.uSchVec(3));
set(handles.edit_uSchVec3, 'String', par.uSchVec(4));
set(handles.edit_uSchVec4, 'String', par.uSchVec(5));
set(handles.edit_uSchVec5, 'String', par.uSchVec(6));

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

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


% --- Executes during object creation, after setting all properties.
function popup_umodType_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popup_umodType (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



function edit_uSchVecp1_Callback(hObject, eventdata, handles)
% hObject    handle to edit_uSchVecp1 (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 edit_uSchVecp1 as text
%        str2double(get(hObject,'String')) returns contents of edit_uSchVecp1 as a double
uSchVecp1 = get(handles.edit_uSchVecp1,'Value');
a = cell(7-uSchVecp1,1);for i = 1:7-uSchVecp1, a{i} = sprintf('%d', i);end
set(handles.edit_uSchVecp2, 'String', a);
set(handles.edit_uSchVecp2, 'Value', 1);

% --- Executes during object creation, after setting all properties.
function edit_uSchVecp1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_uSchVecp1 (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



function edit_uSchVecp2_Callback(hObject, eventdata, handles)
% hObject    handle to edit_uSchVecp2 (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 edit_uSchVecp2 as text
%        str2double(get(hObject,'String')) returns contents of edit_uSchVecp2 as a double


% --- Executes during object creation, after setting all properties.
function edit_uSchVecp2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_uSchVecp2 (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



function edit_uSchVec0_Callback(hObject, eventdata, handles)
% hObject    handle to edit_uSchVec0 (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 edit_uSchVec0 as text
%        str2double(get(hObject,'String')) returns contents of edit_uSchVec0 as a double


% --- Executes during object creation, after setting all properties.
function edit_uSchVec0_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_uSchVec0 (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



function edit_uSchVec1_Callback(hObject, eventdata, handles)
% hObject    handle to edit_uSchVec1 (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 edit_uSchVec1 as text
%        str2double(get(hObject,'String')) returns contents of edit_uSchVec1 as a double


% --- Executes during object creation, after setting all properties.
function edit_uSchVec1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_uSchVec1 (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



function edit_uSchVec2_Callback(hObject, eventdata, handles)
% hObject    handle to edit_uSchVec2 (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 edit_uSchVec2 as text
%        str2double(get(hObject,'String')) returns contents of edit_uSchVec2 as a double


% --- Executes during object creation, after setting all properties.
function edit_uSchVec2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_uSchVec2 (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



function edit_uSchVec3_Callback(hObject, eventdata, handles)
% hObject    handle to edit_uSchVec3 (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 edit_uSchVec3 as text
%        str2double(get(hObject,'String')) returns contents of edit_uSchVec3 as a double


% --- Executes during object creation, after setting all properties.
function edit_uSchVec3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_uSchVec3 (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



function edit_uSchVec4_Callback(hObject, eventdata, handles)
% hObject    handle to edit_uSchVec4 (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 edit_uSchVec4 as text
%        str2double(get(hObject,'String')) returns contents of edit_uSchVec4 as a double


% --- Executes during object creation, after setting all properties.
function edit_uSchVec4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_uSchVec4 (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



function edit_uSchVec5_Callback(hObject, eventdata, handles)
% hObject    handle to edit_uSchVec5 (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 edit_uSchVec5 as text
%        str2double(get(hObject,'String')) returns contents of edit_uSchVec5 as a double


% --- Executes during object creation, after setting all properties.
function edit_uSchVec5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_uSchVec5 (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



function edit_noiseSeed_Callback(hObject, eventdata, handles)
% hObject    handle to edit_noiseSeed (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 edit_noiseSeed as text
%        str2double(get(hObject,'String')) returns contents of edit_noiseSeed as a double


% --- Executes during object creation, after setting all properties.
function edit_noiseSeed_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_noiseSeed (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



function edit_channelSeed_Callback(hObject, eventdata, handles)
% hObject    handle to edit_channelSeed (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 edit_channelSeed as text
%        str2double(get(hObject,'String')) returns contents of edit_channelSeed as a double


% --- Executes during object creation, after setting all properties.
function edit_channelSeed_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_channelSeed (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



function edit_NIteraci_Callback(hObject, eventdata, handles)
% hObject    handle to edit_NIteraci (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 edit_NIteraci as text
%        str2double(get(hObject,'String')) returns contents of edit_NIteraci as a double


% --- Executes during object creation, after setting all properties.
function edit_NIteraci_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_NIteraci (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 checkbox_vyrovKanal.
function checkbox_vyrovKanal_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox_vyrovKanal (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 checkbox_vyrovKanal
