function varargout = simulace11(varargin)
%Tato funkce simuluje chovani systemu s jednou linkou obshluhy a maximalnim
%poctem zakazniku v systemu rovnym jedne. Tedy pokud zakaznik prichazi k
%obsazene lince obsluhy, odchazi bez obslouzeni. Zaroven tato funkce pocita
%i odpovidajici teoreticke vystupni parametry dane teorii markovskych
%retezcu se spojitym casem. Funkce tez vykresluje emiricke distribucni 
%funkce rozlozeni casu mezi prichody zakazniku a doby obsluhy zakazniku, 
%ktere tato funkce simuluje, s prolozenim odpovidajicich teoretickych
%distribucnich funkci (exponencialniho rozlozeni s prislusnymi parametry 
%- lambda, mi).
%Po spusteni funkce uzivatel zada do prislusnych editovacich oken 
%odpovidajici vstupni parametry. V dalsim kroku si bud zakliknutim vybere
%vystupni parametry, ktere chce vypocitat, nebo si vybere vsechny vystupni
%parametry pomoci tlacitka 'Vyber vse'. Pro vypocet slouzi tlacitko
%'Vypocitej'. Tlacitko 'Vycisti vse' vycisti opravdu vsechno - vstupni,
%vystupni parametry, grafy, chybove hlasky i zakliknute moznosti. 
%vstupni parametry:
%   lambda...intenzita vstupniho proudu - musi byt kladne cislo
%   mi...intenzita obsuhy - musi byt kladne cislo
%   CPS...celkovy pocet simulaci - musi byt kladne cislo
%vystupni parametry simulace:
%   prumer_IMP...prumerna doba mezi prichody zakazniku
%   prumer_DO...prumerna doba obsluhy
%   PZZ...odhad pravdep., ze prichozi zakaznik bude odmitnut
%   lambdaPP...prumerny pocet zakazniku za jednotku casu
%   lambdaZZ...prumerny pocet odmitnutych zakazniku za jedn. casu
%   kapakapa...vyuziti systemu
%   prumer_NLO...prumerna doba nevyuziti linky obsluhy
%   ENSS...prumerny pocet obsluhovanych zakazniku
%   p...odhady pravdepodobnosti poctu zakazniku v systemu 
%odpovidajici teoreticke vystupni parametry:
%   EWS...stredni hodnota doby obsluhy
%   PZ...pravdepodobnost,ze prichozi zakaznik bude odmitnut
%   lambdaP...stredni hodnota poctu zakazniku za jednotku casu
%   lambdaZ...stredni hodnota poctu odmitnutych zakazniku za jednotku casu
%   kapa...vyuziti systemu
%   ENS...stredni hodnota poctu obsluhovanych zakazniku
%   a...stacionarni rozlozeni systemu
%--------------------------------------------------------------------------
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @simulace11_OpeningFcn, ...
                   'gui_OutputFcn',  @simulace11_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 simulace11 is made visible.
function simulace11_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 simulace11 (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = simulace11_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 edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (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 edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double


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

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



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


% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (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 edit3_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (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 edit3 as text
%        str2double(get(hObject,'String')) returns contents of edit3 as a double


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


% --- Executes on button press in checkbox2.
function checkbox2_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox2 (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


% --- Executes on button press in checkbox3.
function checkbox3_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox3 (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


% --- Executes on button press in checkbox4.
function checkbox4_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox4 (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


% --- Executes on button press in checkbox5.
function checkbox5_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox5 (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


% --- Executes on button press in checkbox6.
function checkbox6_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox6 (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


% --- Executes on button press in checkbox7.
function checkbox7_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox7 (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 checkbox7


% --- Executes on button press in checkbox8.
function checkbox8_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox8 (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 checkbox8


% --- Executes on button press in checkbox9.
function checkbox9_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox9 (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 checkbox9


% --- Executes on button press in checkbox10.
function checkbox10_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox10 (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 checkbox10


% --- Executes on button press in checkbox11.
function checkbox11_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox11 (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 checkbox11


% --- Executes on button press in checkbox12.
function checkbox12_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox12 (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 checkbox12


% --- Executes on button press in checkbox13.
function checkbox13_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox13 (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 checkbox13


% --- Executes on button press in checkbox14.
function checkbox14_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox14 (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 checkbox14


% --- Executes on button press in checkbox15.
function checkbox15_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox15 (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 checkbox15


% --- Executes on button press in checkbox16.
function checkbox16_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox16 (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 checkbox16


% --- Executes on button press in checkbox17.
function checkbox17_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox17 (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 checkbox17


% --- Executes on button press in checkbox18.
function checkbox18_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox18 (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 checkbox18


% --- Executes on button press in checkbox19.
function checkbox19_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox19 (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 checkbox19


% --- Executes on button press in checkbox20.
function checkbox20_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox20 (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 checkbox20


% --- Executes on button press in checkbox21.
function checkbox21_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox21 (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 checkbox21


% --- Executes on button press in checkbox22.
function checkbox22_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox22 (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 checkbox22


% --- Executes on button press in checkbox23.
function checkbox23_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox23 (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 checkbox23


% --- Executes on button press in checkbox24.
function checkbox24_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox24 (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 checkbox24


% --- Executes on button press in checkbox25.
function checkbox25_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox25 (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 checkbox25


% --- Executes on button press in checkbox26.
function checkbox26_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox26 (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 checkbox26


% --- Executes on button press in checkbox27.
function checkbox27_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox27 (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 checkbox27


% --- Executes on button press in checkbox28.
function checkbox28_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox28 (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 checkbox28


% --- Executes on button press in checkbox29.
function checkbox29_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox29 (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 checkbox29


% --- Executes on button press in checkbox30.
function checkbox30_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox30 (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 checkbox30


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

%tlacitko vypocitej
%-----------------------------------------------------------------------
%vycisteni plochy
set(handles.text8,'String','');
set(handles.text16,'String','');
set(handles.text62,'String','');
set(handles.text61,'String','');
set(handles.text23,'String','');
set(handles.text24,'String','');
set(handles.text25,'String','');
set(handles.text64,'String','');
set(handles.text27,'String','');
set(handles.text28,'String','');
set(handles.text50,'String','');
set(handles.text60,'String','');
set(handles.text63,'String','');
set(handles.text54,'String','');
set(handles.text55,'String','');
set(handles.text57,'String','');
set(handles.text58,'String','');
set(handles.text59,'String','');
cla(handles.axes1);
cla(handles.axes3);
%nacteni vstupnich parametru
lambda=str2double(get(handles.edit1,'String'));
mi=str2double(get(handles.edit2,'String'));
CPS=str2double(get(handles.edit3,'String'));
if lambda<=0
    set(handles.text59,'String','Intenzita vstupniho proudu musi byt kladne cislo.');
else
    if mi<=0
        set(handles.text59,'String','Intenzita obsluhy musi byt kladne cislo.');
    else
        if CPS<=0
            set(handles.text59,'String','Celkovy pocet simulaci musi byt kladne cislo.');
        else
IMP=exprnd(1/lambda,CPS,1);
%IMP ... intervaly mezi prichody zakazniku
DO=exprnd(1/mi,CPS,1);
%DO ... doba obsluhy zakaznika
OPZ=cumsum(IMP);
%OPZ ... okamziky prichodu zakazniku
OOZ(1)=OPZ(1)+DO(1);
ZO(1)=OPZ(1);
%OOZ ... okamziky odchodu zakazniku
%ZO ... zacatek obsluhy zakaznika
pomocny=OOZ;
DOO(1)=DO(1);
j=1;
for i=2:CPS
    if OPZ(i)<pomocny(i-1)
        ZO(i)=0;
        pomocny(i)=pomocny(i-1);
        OOZ(i)=OPZ(i);
    else
        j=j+1;
        ZO(i)=OPZ(i);
        OOZ(i)=ZO(i)+DO(i);
        DOO(j)=DO(i);
        pomocny(i)=OOZ(i);
    end
end
OOZ=OOZ';
ZO=ZO';
%NLO ... nevyuziti linky obsluhy
%pp ... vektor poctu zakazniku v systemu
NLO(1)=pomocny(1);
pp(1)=1;
for i=2:CPS
    if pomocny(i)>pomocny(i-1)
        NLO(i)=ZO(i)-OOZ(i-1);
        pp(i)=0;
    else
        NLO(i)=0;
        pp(i)=1;
    end
end
NLO=NLO';
DOO=DOO';
%prumer_IMP ... prumerna doba mezi prichody zakazniku
prumer_IMP=mean(IMP);
%prumer_DO ... prumerna doba obsluhy
prumer_DO=mean(DOO);
%odhad_lambda...odhad intenzity vstupniho proudu
odhad_lambda=1/prumer_IMP;
%prumer_NLO ... prumerna doba nevyuziti linky obsluhy
prumer_NLO=mean(NLO);
%p ... odhady pravdepodobnosti poctu zakazniku v systemu
p(1)=length(find(pp==0))/CPS;
p(2)=length(find(pp==1))/CPS;
%PZZ...odhad pravdep., ze prichozi zakaznik bude odmitnut
PZZ=p(2);
%lambdaPP ... prumerny pocet zakazniku za jednotku casu
lambdaPP=odhad_lambda*(1-PZZ);
%lambdaZZ ... prumerny pocet odmitnutych zakazniku za jedn. casu
lambdaZZ=odhad_lambda*PZZ;
%ENSS ...prumerny pocet obsluhovanych zakazniku
ENSS=0*p(1)+1*p(2);
%kapakapa ... vyuziti systemu
kapakapa=p(2);
%vystupni parametry:
 %prumer_IMP ... prumerna doba mezi prichody zakazniku
 %prumer_DO ... prumerna doba obsluhy
 %PZZ ... odhad pravdep., ze prichozi zakaznik bude odmitnut
 %lambdaPP ... prumerny pocet zakazniku za jednotku casu
 %lambdaZZ ... prumerny pocet odmitnutych zakazniku za jedn. casu
 %kapakapa ... vyuziti systemu
 %prumer_NLO ... prumerna doba nevyuziti linky obsluhy
 %ENSS ... prumerny pocet obsluhovanych zakazniku
 %p ... odhady pravdepodobnosti poctu zakazniku v systemu
if get(handles.checkbox1,'Value')==1
    set(handles.text8,'String',num2str(prumer_IMP,4));
else
    set(handles.text8,'String','');
end;
if get(handles.checkbox2,'Value')==1
    set(handles.text16,'String',num2str(prumer_DO,4));
else
    set(handles.text16,'String','');
end;
if get(handles.checkbox32,'Value')==1
    set(handles.text62,'String',num2str(PZZ,4));
else
    set(handles.text62,'String','');
end;
if get(handles.checkbox33,'Value')==1
    set(handles.text61,'String',num2str(lambdaPP,4));
else
    set(handles.text61,'String','');
end;
if get(handles.checkbox36,'Value')==1
    set(handles.text64,'String',num2str(lambdaZZ,4));
else
    set(handles.text64,'String','');
end;
if get(handles.checkbox6,'Value')==1
    set(handles.text24,'String',num2str(kapakapa,4));
else
    set(handles.text24,'String','');
end;
if get(handles.checkbox5,'Value')==1
    set(handles.text25,'String',num2str(prumer_NLO,4));
else
    set(handles.text25,'String','');
end;
if get(handles.checkbox9,'Value')==1
    set(handles.text27,'String',num2str(ENSS,4));
else
    set(handles.text27,'String','');
end;
if get(handles.checkbox10,'Value')==1
    set(handles.text28,'String',mat2str(p,4));
else
    set(handles.text28,'String','');
end;

%odpovidajici teoreticke vystupni parametry:
%   EWS...stredni hodnota doby obsluhy
%   PZ...pravdepodobnost,ze prichozi zakaznik bude odmitnut
%   lambdaP...stredni hodnota poctu zakazniku za jednotku casu
%   lambdaZ...stredni hodnota poctu odmitnutych zakazniku za jednotku casu
%   kapa...vyuziti systemu
%   ENS...stredni hodnota poctu obsluhovanych zakazniku
%   a...stacionarni rozlozeni systemu
%----------------------------------------------------------------------------
%   n...pocet linek obsluhy
%   m...omezeni poctu zakazniku v systemu
n=1;
m=1;
beta=lambda/mi;
rho=beta/n;
pom1=0;
for j=0:m
 if j<n
    pom1=pom1+beta^j/factorial(j); 
 else
    pom1=pom1+((n^n)/factorial(n))*rho^j;
 end;
end;
a(1)=1/pom1;
for j=1:m
 if j<=n
    a(j+1)=(beta^j/factorial(j))*a(1); 
 else
    a(j+1)=(((n^n)/factorial(n))*rho^j)*a(1);
 end;
end;
PZ=a(m+1);
lambdaP=lambda*(1-PZ);
lambdaZ=lambda*PZ;
ENS=beta*(1-PZ);
EWS=1/mi;  %www.uai.fme.vutbr.cz/~jdvorak/vyuka/tsoa/PredO11.ppt
kapa=rho*(1-PZ);

if get(handles.checkbox22,'Value')==1
    set(handles.text50,'String',num2str(EWS,4));
else
    set(handles.text50,'String','');
end;
if get(handles.checkbox31,'Value')==1
    set(handles.text60,'String',num2str(PZ,4));
else
    set(handles.text60,'String','');
end;
if get(handles.checkbox34,'Value')==1
    set(handles.text63,'String',num2str(lambdaP,4));
else
    set(handles.text63,'String','');
end;
if get(handles.checkbox35,'Value')==1
    set(handles.text55,'String',num2str(lambdaZ,4));
else
    set(handles.text55,'String','');
end;
if get(handles.checkbox26,'Value')==1
    set(handles.text54,'String',num2str(kapa,4));
else
    set(handles.text54,'String','');
end;
if get(handles.checkbox29,'Value')==1
    set(handles.text57,'String',num2str(ENS,4));
else
    set(handles.text57,'String','');
end;
if get(handles.checkbox30,'Value')==1
    set(handles.text58,'String',mat2str(a,4));
else
    set(handles.text58,'String','');
end;

%vykresleni grafu empiricke a teoreticke distribucni funkce pro IMP a DO
%IMP
%zjisteni vhodneho poctu intevralu - Sturgesovo pravidlo
numIntervals = 1+3.32*log(CPS); 
%zjisteni delky intervalu
intervalWidth=(max(IMP) - min(IMP))/numIntervals;
%tvorba intervalu
x=0:intervalWidth:max(IMP);
%spocitani poctu hodnot v jednotlivych intervalech
ncount=histc(IMP,x);
%spocitani bodu pro empirickou distribucni funkci
souct=cumsum(ncount)./sum(ncount);
%popsani os
xlabel(handles.axes1,'x - intervaly mezi prichody zakazniku (IMP)')
ylabel(handles.axes1,'F(x)')
%vykresleni empiricke distribucni funkce
stairs(handles.axes1,x,souct)
%spocitani bodu distribucni funkce exponencialniho rozdeleni s danym
%parametrem
Y=expcdf(x,1/lambda);
%vykresleni distribucni funkce exponencialniho rozdeleni s danym
%parametrem
plot(handles.axes1,x,Y,'r')
%legenda
legend(handles.axes1,'Empiricka distribucni funkce pro IMP',...
'Teoreticka distribucni funkce pro IMP','Location','SouthEast')
%to same pro DO
intervalWidth=(max(DOO) - min(DOO))/numIntervals;
x2=0:intervalWidth:max(DOO);
ncount2=histc(DOO,x2);
souct2=cumsum(ncount2)./sum(ncount2);
xlabel(handles.axes3,'x - doba obsluhy zakazniku (DO)')
ylabel(handles.axes3,'F(x)') 
stairs(handles.axes3,x2,souct2)
Y2=expcdf(x2,1/mi);
plot(handles.axes3,x2,Y2,'r')
legend(handles.axes3,'Empiricka distribucni funkce pro DO',...
    'Teoreticka distribucni funkce pro DO','Location','SouthEast')
end;
end;
end;


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

%tlacitko vycisti vse
set(handles.edit1,'String','');
set(handles.edit2,'String','');
set(handles.edit3,'String','');
set(handles.text8,'String','');
set(handles.text16,'String','');
set(handles.text25,'String','');
set(handles.text62,'String','');
set(handles.text61,'String','');
set(handles.text23,'String','');
set(handles.text24,'String','');
set(handles.text64,'String','');
set(handles.text27,'String','');
set(handles.text28,'String','');
set(handles.text50,'String','');
set(handles.text60,'String','');
set(handles.text63,'String','');
set(handles.text54,'String','');
set(handles.text55,'String','');
set(handles.text57,'String','');
set(handles.text58,'String','');
set(handles.text59,'String','');
set(handles.checkbox1,'Value',0);
set(handles.checkbox2,'Value',0);
set(handles.checkbox5,'Value',0);
set(handles.checkbox32,'Value',0);
set(handles.checkbox33,'Value',0);
set(handles.checkbox5,'Value',0);
set(handles.checkbox6,'Value',0);
set(handles.checkbox36,'Value',0);
set(handles.checkbox9,'Value',0);
set(handles.checkbox10,'Value',0);
set(handles.checkbox22,'Value',0);
set(handles.checkbox31,'Value',0);
set(handles.checkbox26,'Value',0);
set(handles.checkbox35,'Value',0);
set(handles.checkbox34,'Value',0);
set(handles.checkbox29,'Value',0);
set(handles.checkbox30,'Value',0);
cla(handles.axes1);
cla(handles.axes3);


% --- Executes during object deletion, before destroying properties.
function axes1_DeleteFcn(hObject, eventdata, handles)
% hObject    handle to axes1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


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

%tlacitko vyber vse
set(handles.checkbox1,'Value',1);
set(handles.checkbox2,'Value',1);
set(handles.checkbox5,'Value',1);
set(handles.checkbox32,'Value',1);
set(handles.checkbox33,'Value',1);
set(handles.checkbox5,'Value',1);
set(handles.checkbox6,'Value',1);
set(handles.checkbox36,'Value',1);
set(handles.checkbox9,'Value',1);
set(handles.checkbox10,'Value',1);
set(handles.checkbox22,'Value',1);
set(handles.checkbox31,'Value',1);
set(handles.checkbox26,'Value',1);
set(handles.checkbox34,'Value',1);
set(handles.checkbox35,'Value',1);
set(handles.checkbox29,'Value',1);
set(handles.checkbox30,'Value',1);


% --- Executes on button press in checkbox31.
function checkbox31_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox31 (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 checkbox31


% --- Executes on button press in checkbox32.
function checkbox32_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox32 (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 checkbox32


% --- Executes on button press in checkbox33.
function checkbox33_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox33 (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 checkbox33


% --- Executes on button press in checkbox34.
function checkbox34_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox34 (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 checkbox34


% --- Executes on button press in checkbox35.
function checkbox35_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox35 (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 checkbox35


% --- Executes on button press in checkbox36.
function checkbox36_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox36 (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 checkbox36
