function GUI_compare

scrsz = get(0,'ScreenSize');

% vytvoreni noveho okna pro zobrazeni segmentu

main_window = figure('Units','characters',...
            'HandleVisibility','callback',...
            'Renderer','painters',...
            'numbertitle','off', ...
            'MenuBar','none', ...
            'name','Wave comparsion', ...
            'Units','pixels', ... 
            'Position',[scrsz(3)/6 scrsz(4)/5 scrsz(3)/1.5 scrsz(4)/1.5]);

menu_new = uimenu(main_window,'Label','Wave'); 
 
create_marks = uimenu(menu_new,'Label','Load waves',... 
              'Callback',{@load_Callback});        
          
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% VARIABLES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
pom = 1;
r_data = [];
r_data_n = [];
max_data = 0;
osa = [];
freq = 1000;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% FUNCTIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         
      function load_Callback(source,eventdata)                   
          [filename pathname] = uigetfile({'*.mat'},'File Selector');

          if(filename==0)
              msgbox('There is no file to load');
              return;
          end
          
          path = strcat(pathname,filename);         
          data1 = load(path);
%           data1.m_wave
          data = data1.m_wave;
          % normalization
          data = (data-min(data))/(max(data)-min(data)); 
           
          if(pom==1)
              plot_signals(data)
              resample_signals(data)
          else
              resample_signals(data)
          end
        
          pom = pom+1;                
      end
    
      
      function plot_signals(data)
          labels = {'21-28','29-36','37-44','45-52', '53-60','61-'};
          legendInfo = {};
          osa = (1/freq:1/freq:length(data)/freq);
          [x2 y2] = size(data);
          plotStyle = {'b','r','k','g','y'}; 
          
          if(pom==1)
            plot(osa,data);
          else
              for i=1:x2
                plot(osa,data(i,:),plotStyle{i})
                         legendInfo{i} = [' Mean wave - ' num2str(i)];
                hold on;
              end
              hold off;  
          end
          zoom on;
          legend(labels)
          xlabel('normovane t [s] dle nejdelsi vlny');
          ylabel('normovana amplituda [-]');
          
      end
  
  
      function resample_signals(data)

                   
          if(pom==1)
          r_data(pom,:) = data; 
          end
          
          [x y] = size(r_data);
          
          if(length(data)>max_data && pom>1)
          max_data = length(data);        
            for i=1:x
            r_data_n(i,:) = resample(r_data(i,:),max_data,length(r_data));
%             r_data_n(i,:) = [r_data(i,:),nan(1,max_data-y)];
            
            end
          r_data_n(x+1,:) = data;     
            
         %% plot data
          plot_signals(r_data_n)              
          r_data = r_data_n;
          r_data_n = [];
          elseif(length(data)<=max_data && pom>1)
            r_data(x+1,:) = resample(data,max_data,length(data)); 
%             r_data(x+1,:) = [data,nan(1,max_data-length(data))];
          plot_signals(r_data)    
          end
                    
      end
  
end