
function varargout = bc(varargin)

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

% Last Modified by GUIDE v2.5 16-May-2013 19:07:12

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

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = bc_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 slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject    handle to slider1 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider


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

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


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

% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu1
% global s
% s = get(handles.popupmenu1,'Value');
% switch s
%     case 2
%         set(handles.text7,'String','Zvolte anodové napětí od 30 do 140kV') % wolfram
%     case 3 
%         set(handles.text7,'String','Zvolte anodové napětí od 18 do 40kV')  % rhodium
%     case 4
%         set(handles.text7,'String','Zvolte anodové napětí od 18 do 40kV')  % molybden
%   
% end


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

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


% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu2 (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 popupmenu2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu2


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

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


% --- Executes on selection change in popupmenu3.
function popupmenu3_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu3 (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 popupmenu3 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu3


% Al:   0.5mm 1mm 2mm 3mm
% Cu: 0.1mm 0.2mm 0.3mm
% Ta:  0.01mm 0.02mm 0.03mm
mat = get(handles.popupmenu3,'Value');

switch mat
    
    case 2
        set(handles.text9,'String','Al: 0.3mm 0.4mm 0.5mm 0.6mm 0.8mm 1mm');
    case 3
        set(handles.text9,'String','Cu: 0.1mm 0.2mm 0.4mm 0.6mm 0.8mm 1mm');
    case 4
        set(handles.text9,'String','Ta: 0.004mm 0.006mm 0.008mm 0.01mm 0.015mm 0.02mm');
end

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

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


% --- Executes on slider movement.
function slider2_Callback(hObject, eventdata, handles)
% hObject    handle to slider2 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider


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

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on selection change in popupmenu6.
function popupmenu6_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu6 (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 popupmenu6 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu6


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

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


% --- Executes on selection change in popupmenu7.
function popupmenu7_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu7 (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 popupmenu7 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu7


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

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


% --- Executes on button press in 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)

global s

load wolfram.mat;
%proud = str2num(get(handles.edit3,'String'));
mat = get(handles.popupmenu3,'Value');
nap = str2num(get(handles.edit2,'String'));
tl = str2num(get(handles.edit1,'String'));
col = nap;

%%  Vzduch

if mat == 1
   figure (1);
   plot(Wnefilt(:,nap-29));
   max(Wnefilt(:,nap-29));
   set(handles.text10,'String', max(Wnefilt(:,nap-29)));
   title('Nefiltrované spektrum');
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   set(gca,'XTick',[0:10:140]);

% %   Aluminium

    elseif mat == 2
   ro = 2700;
   z = 13;
   kol = 30;
   switch tl
       
       case 0.3
    nap = nap - 29; 
    I = zeros(50,1);
    [rad slo] = size(Wnefilt(:,nap))
    for i = 2 : rad
        if nap <= 64
       mi = 2322*kol.^(-1.97);
       I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
       kol = kol + 1;
       else 
       mi = 11.52*kol.^(-0.69);  
       I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
       kol = kol + 1;
        end
       
    end
  
   figure (1);
   plot(Wnefilt(:,nap));
   max(Wnefilt(:,nap));
   set(handles.text10,'String', max(Wnefilt(:,nap)));
   title('Nefiltrované spektrum')
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   set(gca,'XTick',[0:10:140]);
   figure(2);
   plot(Wnefilt(:,nap));
   hold on;
   plot(I(:,1),'g');
   title('filtrace RTG záření');
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   legend('Nefiltrované spektrum','Filtrované spektrum, Al filtr') ;
   set(gca,'XTick',[0:10:140]);
   figure(3);
   plot(I(:,1),'g');
   max(I);
   set(handles.text13,'String',max(I));
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Filtrované spektrum, Al filtr')
   set(gca,'XTick',[0:10:140]);
   
 
       case 0.4
    nap = nap - 29; 
    kol = 30;
   [rad slo] = size(Wnefilt(:,nap))
    for i = 2 : rad
         if nap <= 64
       mi = 2322*kol.^(-1.97);
       I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
       kol = kol + 1;
       else 
       mi = 11.52*kol.^(-0.69);  
       I(i,1) = Wnefilt(i,col-29)*exp(-(mi)*tl);
       kol = kol + 1;
         end
      %  save I.mat
    end
   figure (1);
   plot(Wnefilt(:,nap));
   max(Wnefilt(:,nap));
   set(handles.text10,'String', max(Wnefilt(:,nap)));
   title('Nefiltrované spektrum')
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   set(gca,'XTick',[0:10:140]);
   figure(2);
   plot(Wnefilt(:,nap));
   hold on;
   plot(I(:,1),'g');
   title('filtrace RTG záření');
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   legend('Nefiltrované spektrum','Filtrované spektrum, Al filtr') ;
   set(gca,'XTick',[0:10:140]);
   figure(3);
   plot(I(:,1),'g');
   max(I);
   set(handles.text13,'String',max(I));
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Filtrované spektrum, Al filtr')
   set(gca,'XTick',[0:10:140]);
   
  
          case 0.5
             
   nap = nap - 29;
   kol = 30;
   [rad slo] = size(Wnefilt(:,nap))
   for i = 2 : rad
     if nap <= 64
       mi = 2322*kol.^(-1.97);
       I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
       kol = kol + 1;
       else 
       mi = 11.52*kol.^(-0.69);  
       I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
       kol = kol + 1;
     end
       
    end
   figure (1);
   plot(Wnefilt(:,nap));
   max(Wnefilt(:,nap));
   set(handles.text10,'String', max(Wnefilt(:,nap)));
   title('Nefiltrované spektrum')
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   set(gca,'XTick',[0:10:140]);
   figure(2);
   plot(Wnefilt(:,nap));
   hold on;
   plot(I(:,1),'g');
   title('filtrace RTG záření');
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   legend('Nefiltrované spektrum','Filtrované spektrum, Al filtr') ;
   set(gca,'XTick',[0:10:140]);
   figure(3);
   plot(I(:,1),'g');
   max(I);
   set(handles.text13,'String',max(I));
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Filtrované spektrum, Al filtr')
   set(gca,'XTick',[0:10:140]);
    
   
   case 0.6
   nap = nap - 29;
   kol = 30;
   [rad slo] = size(Wnefilt(:,nap))
   for i = 2 : rad
     if nap <= 64
       mi = 2322*kol.^(-1.97);
       I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
       kol = kol + 1;
       else 
       mi = 11.52*kol.^(-0.69);  
       I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
       kol = kol + 1;
     end
       
    end
   figure (1);
   plot(Wnefilt(:,nap));
   max(Wnefilt(:,nap));
   set(handles.text10,'String', max(Wnefilt(:,nap)));
   title('Nefiltrované spektrum')
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   set(gca,'XTick',[0:10:140]);
   figure(2);
   plot(Wnefilt(:,nap));
   hold on;
   plot(I(:,1),'g');
   title('filtrace RTG záření');
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   legend('Nefiltrované spektrum','Filtrované spektrum, Al filtr') ;
   set(gca,'XTick',[0:10:140]);
   figure(3);
   plot(I(:,1),'g');
   max(I);
   set(handles.text13,'String',max(I));
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Filtrované spektrum, Al filtr')
   set(gca,'XTick',[0:10:140]);
  
    case 0.8
             
   nap = nap - 29;
   kol = 30;
   [rad slo] = size(Wnefilt(:,nap))
   for i = 2 : rad
     if nap <= 64
       mi = 2322*kol.^(-1.97);
       I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
       kol = kol + 1;
       else 
       mi = 11.52*kol.^(-0.69);  
       I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
       kol = kol + 1;
     end
       
    end
   figure (1);
   plot(Wnefilt(:,nap));
   max(Wnefilt(:,nap));
   set(handles.text10,'String', max(Wnefilt(:,nap)));
   title('Nefiltrované spektrum')
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   set(gca,'XTick',[0:10:140]);
   figure(2);
   plot(Wnefilt(:,nap));
   hold on;
   plot(I(:,1),'g');
   title('filtrace RTG záření');
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   legend('Nefiltrované spektrum','Filtrované spektrum, Al filtr') ;
   set(gca,'XTick',[0:10:140]);
   figure(3);
   plot(I(:,1),'g');
   max(I);
   set(handles.text13,'String',max(I));
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Filtrované spektrum, Al filtr')
   set(gca,'XTick',[0:10:140]);
   
   
    case 1
             
   nap = nap - 29;
   kol = 30;
   [rad slo] = size(Wnefilt(:,nap))
   for i = 2 : rad
     if nap <= 64
       mi = 2322*kol.^(-1.97);
       I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
       kol = kol + 1;
       else 
       mi = 11.52*kol.^(-0.69);  
       I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
       kol = kol + 1;
     end
       
    end
   figure (1);
   plot(Wnefilt(:,nap));
   max(Wnefilt(:,nap));
   set(handles.text10,'String', max(Wnefilt(:,nap)));
   title('Nefiltrované spektrum')
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   set(gca,'XTick',[0:10:140]);
   figure(2);
   plot(Wnefilt(:,nap));
   hold on;
   plot(I(:,1),'g');
   title('filtrace RTG záření');
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   legend('Nefiltrované spektrum','Filtrované spektrum, Al filtr') ;
   set(gca,'XTick',[0:10:140]);
   figure(3);
   plot(I(:,1),'g');
   max(I);
   set(handles.text13,'String',max(I));
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Filtrované spektrum, Al filtr')
   set(gca,'XTick',[0:10:140]);
   
     end
%%      Měď
       elseif mat == 3
    kol = 30;
         switch tl
             
       case 0.1
   nap = nap - 29; 
   [rad slo] = size(Wnefilt(:,nap))
   for i = 2 : rad
       mi = 44421*kol.^-2.51;
    I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
    kol = kol + 1;
   end
   
   figure(1);
   plot(Wnefilt(:,nap));
   max(Wnefilt(:,nap));
   set(handles.text10,'String', max(Wnefilt(:,nap)));
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Nefiltrované spektrum')
   set(gca,'XTick',[0:10:140]);
   figure(2);
   plot(Wnefilt(:,nap));
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   hold on;
   plot(I(:,1),'g');
   title('filtrace RTG záření');
   legend('Nefiltrované spektrum','Filtrované spektrum, Cu filtr');
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   set(gca,'XTick',[0:10:140]);
   figure(3);
   plot(I(:,1),'g');
   max(I);
   set(handles.text13,'String',max(I));
   title('Filtrované spektrum, Cu filtr');
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2]');
   set(gca,'XTick',[0:10:140]);
   
   
       case 0.2
   nap = nap - 29; 
   [rad slo] = size(Wnefilt(:,nap))
    for i = 2 : rad
   mi = 44421*kol.^-2.51;
    I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
    kol = kol + 1;
    end
    
   figure(1);
   plot(Wnefilt(:,nap));
   max(Wnefilt(:,nap));
   set(handles.text10,'String', max(Wnefilt(:,nap)));
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Nefiltrované spektrum')
   set(gca,'XTick',[0:10:140]);
   figure(2);
   plot(Wnefilt(:,nap));
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   hold on;
   plot(I(:,1),'g');
   title('filtrace RTG záření');
   legend('Nefiltrované spektrum','Filtrované spektrum, Cu filtr');
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   set(gca,'XTick',[0:10:140]);
   figure(3);
   plot(I(:,1),'g');
   max(I);
   set(handles.text13,'String',max(I));
   title('Filtrované spektrum, Cu filtr');
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2]');
   set(gca,'XTick',[0:10:140]);
   
   
   
          case 0.4
   nap = nap - 29;
   [rad slo] = size(Wnefilt(:,nap))
   for i = 2 : rad
    mi = 44421*kol.^-2.51;
    I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
    kol = kol + 1;
   end
   
   figure(1);
   plot(Wnefilt(:,nap));
   max(Wnefilt(:,nap));
   set(handles.text10,'String', max(Wnefilt(:,nap)));
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Nefiltrované spektrum')
   set(gca,'XTick',[0:10:140]);
   figure(2);
   plot(Wnefilt(:,nap));
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   hold on;
   plot(I(:,1),'g');
   title('filtrace RTG záření');
   legend('Nefiltrované spektrum','Filtrované spektrum, Cu filtr');
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   set(gca,'XTick',[0:10:140]);
   figure(3);
   plot(I(:,1),'g');
   max(I);
   set(handles.text13,'String',max(I));
   title('Filtrované spektrum, Cu filtr');
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2]');
   set(gca,'XTick',[0:10:140]);
   
   
    case 0.6
   nap = nap - 29; 
   [rad slo] = size(Wnefilt(:,nap))
   for i = 2 : rad
       mi = 44421*kol.^-2.51;
    I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
    kol = kol + 1;
   end
   
   figure(1);
   plot(Wnefilt(:,nap));
   max(Wnefilt(:,nap));
   set(handles.text10,'String', max(Wnefilt(:,nap)));
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Nefiltrované spektrum')
   set(gca,'XTick',[0:10:140]);
   figure(2);
   plot(Wnefilt(:,nap));
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   hold on;
   plot(I(:,1),'g');
   title('filtrace RTG záření');
   legend('Nefiltrované spektrum','Filtrované spektrum, Cu filtr');
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   set(gca,'XTick',[0:10:140]);
   figure(3);
   plot(I(:,1),'g');
   max(I);
   set(handles.text13,'String',max(I));
   title('Filtrované spektrum, Cu filtr');
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2]');
   set(gca,'XTick',[0:10:140]);
   
   
    case 0.8
   nap = nap - 29; 
   [rad slo] = size(Wnefilt(:,nap))
   for i = 2 : rad
       mi = 44421*kol.^-2.51;
    I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
    kol = kol + 1;
   end
   
  figure(1);
   plot(Wnefilt(:,nap));
   max(Wnefilt(:,nap));
   set(handles.text10,'String', max(Wnefilt(:,nap)));
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Nefiltrované spektrum')
   set(gca,'XTick',[0:10:140]);
   figure(2);
   plot(Wnefilt(:,nap));
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   hold on;
   plot(I(:,1),'g');
   title('filtrace RTG záření');
   legend('Nefiltrované spektrum','Filtrované spektrum, Cu filtr');
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   set(gca,'XTick',[0:10:140]);
   figure(3);
   plot(I(:,1),'g');
   max(I);
   set(handles.text13,'String',max(I));
   title('Filtrované spektrum, Cu filtr');
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2]');
   set(gca,'XTick',[0:10:140]);
  
   
    case 1
   nap = nap - 29; 
   [rad slo] = size(Wnefilt(:,nap))
   for i = 2 : rad
       mi = 44421*kol.^-2.51;
    I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
    kol = kol + 1;
   end
   
   figure(1);
   plot(Wnefilt(:,nap));
   max(Wnefilt(:,nap));
   set(handles.text10,'String', max(Wnefilt(:,nap)));
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Nefiltrované spektrum')
   set(gca,'XTick',[0:10:140]);
   figure(2);
   plot(Wnefilt(:,nap));
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   hold on;
   plot(I(:,1),'g');
   title('filtrace RTG záření');
   legend('Nefiltrované spektrum','Filtrované spektrum, Cu filtr');
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   set(gca,'XTick',[0:10:140]);
   figure(3);
   plot(I(:,1),'g');
   max(I);
   set(handles.text13,'String',max(I));
   title('Filtrované spektrum, Cu filtr');
   xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2]');
   set(gca,'XTick',[0:10:140]);
   
         end
%%         Tantal
elseif mat == 4
    Z = 0.46556;
    RO = 7.874;
    kol = 30;
    switch tl
        
       case 0.004
   nap = nap - 29; 
   [rad slo] = size(Wnefilt(:,nap))
   for i = 2 : rad
       if nap <= 67
       mi = 2*10^(6)*(kol.^(-2.60))
       I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
       kol = kol + 1;
       else 
       mi = 1*10^(7)*(kol.^(-2.56))  
       I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
       kol = kol + 1;
       end
    
   end
   figure(1);
   plot(Wnefilt(:,nap));
   max(Wnefilt(:,nap));
   set(handles.text10,'String', max(Wnefilt(:,nap)));
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Nefiltrované spektrum')
   set(gca,'XTick',[0:10:140]);
   figure(2);
   plot(Wnefilt(:,nap));
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   hold on;
   plot(I(:,1),'g');
   title('filtrace RTG záření');
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   legend('Nefiltrované spektrum','Filtrované spektrum, Ta filtr');
   set(gca,'XTick',[0:10:140]);
   figure(3);
   plot(I(:,1),'g');
   max(I);
   set(handles.text13,'String',max(I));
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Filtrované spektrum, Ta filtr')
   set(gca,'XTick',[0:10:140]);
   
   
       case 0.006
   nap = nap - 29; 
   [rad slo] = size(Wnefilt(:,nap))
   for i = 2 : rad
   if nap <= 67
       mi = 2*10^(6)*(kol.^(-2.60))
       I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
       kol = kol + 1;
       else 
       mi = 1*10^(7)*(kol.^(-2.56))  
       I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
       kol = kol + 1;
   end
       
   end
   figure(1);
   plot(Wnefilt(:,nap));
   max(Wnefilt(:,nap));
   set(handles.text10,'String', max(Wnefilt(:,nap)));
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Nefiltrované spektrum')
   set(gca,'XTick',[0:10:140]);
   figure(2);
   plot(Wnefilt(:,nap));
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   hold on;
   plot(I(:,1),'g');
   title('filtrace RTG záření');
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   legend('Nefiltrované spektrum','Filtrované spektrum, Ta filtr');
   set(gca,'XTick',[0:10:140]);
   figure(3);
   plot(I(:,1),'g');
   max(I);
   set(handles.text13,'String',max(I));
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Filtrované spektrum, Ta filtr')
   set(gca,'XTick',[0:10:140]);
   

          case 0.008
   nap = nap - 29;
   [rad slo] = size(Wnefilt(:,nap))
   for i = 2 : rad
     if nap <= 67
       mi = 2*10^(6)*(kol.^(-2.60))
       I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
       kol = kol + 1;
       else 
       mi = 1*10^(7)*(kol.^(-2.56))  
       I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
       kol = kol + 1;
     end
      
   end
   figure(1);
   plot(Wnefilt(:,nap));
   max(Wnefilt(:,nap));
   set(handles.text10,'String', max(Wnefilt(:,nap)));
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Nefiltrované spektrum')
   set(gca,'XTick',[0:10:140]);
   figure(2);
   plot(Wnefilt(:,nap));
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   hold on;
   plot(I(:,1),'g');
   title('filtrace RTG záření');
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   legend('Nefiltrované spektrum','Filtrované spektrum, Ta filtr');
   set(gca,'XTick',[0:10:140]);
   figure(3);
   plot(I(:,1),'g');
   max(I);
   set(handles.text13,'String',max(I));
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Filtrované spektrum, Ta filtr')
   set(gca,'XTick',[0:10:140]);
   
   
    case 0.01
   nap = nap - 29; 
   [rad slo] = size(Wnefilt(:,nap))
   for i = 2 : rad
       if nap <= 67
       mi = 2*10^(6)*(kol.^(-2.60))
       I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
       kol = kol + 1;
       else 
       mi = 1*10^(7)*(kol.^(-2.56))  
       I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
       kol = kol + 1;
       end
    
   end
   figure(1);
   plot(Wnefilt(:,nap));
   max(Wnefilt(:,nap));
   set(handles.text10,'String', max(Wnefilt(:,nap)));
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Nefiltrované spektrum')
   set(gca,'XTick',[0:10:140]);
   figure(2);
   plot(Wnefilt(:,nap));
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   hold on;
   plot(I(:,1),'g');
   title('filtrace RTG záření');
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   legend('Nefiltrované spektrum','Filtrované spektrum, Ta filtr');
   set(gca,'XTick',[0:10:140]);
   figure(3);
   plot(I(:,1),'g');
   max(I);
   set(handles.text13,'String',max(I));
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Filtrované spektrum, Ta filtr')
   set(gca,'XTick',[0:10:140]);
  
    
   
    case 0.015
   nap = nap - 29; 
   [rad slo] = size(Wnefilt(:,nap))
   for i = 2 : rad
       if nap <= 67
       mi = 2*10^(6)*(kol.^(-2.60))
       I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
       kol = kol + 1;
       else 
       mi = 1*10^(7)*(kol.^(-2.56))  
       I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
       kol = kol + 1;
       end
    
   end
  figure(1);
   plot(Wnefilt(:,nap));
   max(Wnefilt(:,nap));
   set(handles.text10,'String', max(Wnefilt(:,nap)));
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Nefiltrované spektrum')
   set(gca,'XTick',[0:10:140]);
   figure(2);
   plot(Wnefilt(:,nap));
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   hold on;
   plot(I(:,1),'g');
   title('filtrace RTG záření');
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   legend('Nefiltrované spektrum','Filtrované spektrum, Ta filtr');
   set(gca,'XTick',[0:10:140]);
   figure(3);
   plot(I(:,1),'g');
   max(I);
   set(handles.text13,'String',max(I));
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Filtrované spektrum, Ta filtr')
   set(gca,'XTick',[0:10:140]);
  
   
   case 0.02
   nap = nap - 29; 
   [rad slo] = size(Wnefilt(:,nap))
   for i = 2 : rad
       if nap <= 67
       mi = 2*10^(6)*(kol.^(-2.60))
       I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
       kol = kol + 1;
       else 
       mi = 1*10^(7)*(kol.^(-2.56))  
       I(i,1) = Wnefilt(i,nap)*exp(-(mi)*tl);
       kol = kol + 1;
       end
    
   end
   figure(1);
   plot(Wnefilt(:,nap));
   max(Wnefilt(:,nap));
   set(handles.text10,'String', max(Wnefilt(:,nap)));
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Nefiltrované spektrum')
   set(gca,'XTick',[0:10:140]);
   figure(2);
   plot(Wnefilt(:,nap));
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   hold on;
   plot(I(:,1),'g');
   title('filtrace RTG záření');
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   legend('Nefiltrované spektrum','Filtrované spektrum, Ta filtr');
   set(gca,'XTick',[0:10:140]);
   figure(3);
   plot(I(:,1),'g');
   max(I);
   set(handles.text13,'String',max(I));
    xlabel('Energie[keV]');ylabel('Intenzita[fot/mm^2.s^-1]');
   title('Filtrované spektrum, Ta filtr')
   set(gca,'XTick',[0:10:140]);
   
   end
end
clear all
clc



% --- Executes on slider movement.
function slider3_Callback(hObject, eventdata, handles)
% hObject    handle to slider3 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider


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

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider4_Callback(hObject, eventdata, handles)
% hObject    handle to slider4 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider


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

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end



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.
global s
o = str2num(get(handles.edit2,'String'));

  if o > 140  
  warndlg('patně zvolená hodnota.', 'ERROR'); 
  elseif o < 30
   warndlg('patně zvolená hodnota.', 'ERROR');    
end

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


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


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



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



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


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