function varargout = MyEntropy(varargin)

%aprbutton-считаем ApEn
%samplebutton-считаем SampEn
%permbutton-считаем PermEn
%edit1 - поле для ввода m
%edit2 - поле для ввода r
%edit3 - поле для вывода e

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @MyEntropy_OpeningFcn, ...
                   'gui_OutputFcn',  @MyEntropy_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   [] );
if nargin & isstr(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 MyEntropy is made visible.
function MyEntropy_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 MyEntropy (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = MyEntropy_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 File_Callback(hObject, eventdata, handles)
% hObject    handle to File (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function Load_Callback(hObject, eventdata, handles)
% hObject    handle to Load (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
MenuFileLoad_Callback;


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

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


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

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


function MenuFileLoad_Callback(h,eventdata,handles)

% читаємо ім"я файла
[FILENAME,PATHNAME,FILTERINDEX]=uigetfile( ...
    {'*.txt;*.dat', 'Файли з даними (*.txt, *.dat)'; ...
     '*.txt',            'Текстові файли (*.txt)'; ...
     '*.dat',            'Текстовий файл з даними (*.dat)'}, ...
     'Виберіть файл з рядом');

if ((FILENAME(1,1)~=0) & (PATHNAME(1,1)~=0))
    % читаємо дані з вибраного файла
   global ryad;
    ryad=load([PATHNAME,FILENAME]);
    [m,n]=size(ryad);
    handles=guidata(gcbo);
    if m~=1
        ryad=ryad';
    end;
    ryad1=ryad';
    set(handles.listbox1,'String','');
  %  p=num2str(ryad1);
    set(handles.listbox1,'String',FILENAME);
    [m,n]=size(ryad);
    s=get(handles.edit5,'Visible');
    if s(2)=='n'
        set(handles.edit3,'String','');
        set(handles.edit4,'String',num2str(n));
        s1=get(handles.aprbutton,'Visible');
        if s1(2)=='n'
            set(handles.edit2,'String',num2str(0.2*std(ryad)));
        end;
    end;
end


% --- 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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
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 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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
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


% --------------------------------------------------------------------
function Methods_Callback(hObject, eventdata, handles)
% hObject    handle to Methods (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function Apen_Callback(hObject, eventdata, handles)
% hObject    handle to Apen (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%Нужно включить aprbutton
global ryad;
[m,n]=size(ryad);
if (m==0) || (n==0)
    messageString=['Завантажте дані!'];
    msgbox(messageString,'');
else
    s=get(handles.edit2,'Visible');
    if s(2)=='f'
        set(handles.edit1,'Visible','on'); % значення для m
        set(handles.edit2,'Visible','on'); % значення для r
        set(handles.edit2,'String',num2str(0.2*std(ryad)));
        set(handles.edit4,'Visible','on'); % значення для ширини вікна
        set(handles.edit4,'String',num2str(n));
        set(handles.edit5,'Visible','on'); % значення для зміщення
        set(handles.text3,'Visible','on'); % m=
        set(handles.text4,'Visible','on'); % r=
        set(handles.text4,'String','Коефіцієнт подібності (r):');
        set(handles.text9,'Visible','on');  % Початкова ширина вікна    
        set(handles.text10,'Visible','on'); % Крок зміщення вікна
        set(handles.aprbutton,'Visible','on');
        set(handles.aprbutton,'String','Обрахувати Approximate entropy');    
    else
        set(handles.edit1,'Visible','on'); % значення для m
        set(handles.text3,'Visible','on'); % m=
        set(handles.edit1,'String','');
        set(handles.edit2,'String','');
        set(handles.edit2,'String',num2str(0.2*std(ryad)));
        set(handles.edit3,'String','');
        set(handles.edit4,'String',num2str(n));
        set(handles.edit5,'String','1');
        set(handles.text4,'String','Коефіцієнт подібності (r):');
        set(handles.aprbutton,'Visible','on');
        set(handles.aprbutton,'String','Обрахувати Approximate entropy');
        set(handles.samplebutton,'Visible','off');
        set(handles.permbutton,'Visible','off');
        set(handles.tsbutton,'Visible','off');
    end;
end;

% --------------------------------------------------------------------
function Sampen_Callback(hObject, eventdata, handles)
% hObject    handle to Sampen (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%Нужно включить samplebutton
global ryad;
[m,n]=size(ryad);
if (m==0) || (n==0)
    messageString=['Завантажте дані!'];
    msgbox(messageString,'');
else
    s=get(handles.edit2,'Visible');
    if s(2)=='f'
        set(handles.edit1,'Visible','on'); % значення для m
        set(handles.edit2,'Visible','on'); % значення для r
        set(handles.edit2,'String','0.2');
        set(handles.edit4,'Visible','on'); % значення для ширини вікна
        set(handles.edit4,'String',num2str(n));
        set(handles.edit5,'Visible','on'); % значення для зміщення    
        set(handles.text3,'Visible','on'); % m=
        set(handles.text4,'Visible','on'); % r=
        set(handles.text4,'String','Коефіцієнт подібності (r):');
        set(handles.text9,'Visible','on');  % Початкова ширина вікна    
        set(handles.text10,'Visible','on'); % Крок зміщення вікна
        set(handles.samplebutton,'Visible','on');
        set(handles.samplebutton,'String','Обрахувати Sample entropy');  
    else
        set(handles.edit1,'Visible','on'); % значення для m
        set(handles.text3,'Visible','on'); % m=
        set(handles.edit1,'String','');
        set(handles.edit2,'String','');
        set(handles.edit2,'String','0.2');
        set(handles.edit3,'String','');
        set(handles.edit4,'String',num2str(n));
        set(handles.edit5,'String','1');
        set(handles.text4,'String','Коефіцієнт подібності (r):');
        set(handles.samplebutton,'Visible','on');
        set(handles.samplebutton,'String','Обрахувати Sample entropy');
        set(handles.aprbutton,'Visible','off');
        set(handles.permbutton,'Visible','off');
        set(handles.tsbutton,'Visible','off');
    end;
end;

% --- 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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
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 on button press in aprbutton.
function aprbutton_Callback(hObject, eventdata, handles)
% hObject    handle to aprbutton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global ryad;
[kk,n]=size(ryad);
m=str2num(get(handles.edit1,'String'));
r=str2num(get(handles.edit2,'String'));
vikno=str2num(get(handles.edit4,'String'));
i=str2num(get(handles.edit5,'String'));
q=0;
if size(m)==[0,0]
    q=q+1;
end;
if size(r)==[0,0]
    q=q+1;
end;
if size(vikno)==[0,0]
    q=q+1;
end;
if vikno>n
    q=q+1;
end;
if size(i)==[0,0]
    q=q+1;
end;
if (q==0)
    global entropymas;
    entropymas=zeros(0,0);
    k=1;
    p=0;
    while (k+vikno-1)<=n
        ryad1=ryad(k:k+vikno-1);
        e=MyApen_new(ryad1,m,r);
        k=k+i;
        p=p+1;
        entropymas(p)=e(m);
        ryad1=[];
    end;
    global mide;
    mide=sum(entropymas)/length(entropymas);
    set(handles.edit3,'String',num2str(mide));
    set(handles.text7,'String','- Approximate Entropy');
else
    messageString=['Заповніть коректно всі поля вхідних параметрів!'];
    msgbox(messageString,'');
end;

% --- Executes on button press in samplebutton.
function samplebutton_Callback(hObject, eventdata, handles)
% hObject    handle to samplebutton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global ryad;
[kk,n]=size(ryad);
m=str2num(get(handles.edit1,'String'));
r=str2num(get(handles.edit2,'String'));
vikno=str2num(get(handles.edit4,'String'));
i=str2num(get(handles.edit5,'String'));
q=0;
if size(m)==[0,0]
   q=q+1;
end;
if size(r)==[0,0]
   q=q+1;
end;
if size(vikno)==[0,0]
    q=q+1;
end;
if vikno>n
    q=q+1;
end;
if size(i)==[0,0]
    q=q+1;
end;
if (q==0)
    global entropymas;
    entropymas=zeros(0,0);
    k=1;
    p=0;
    while (k+vikno-1)<=n
        ryad1=ryad(k:k+vikno-1);
        [e,se,A,B]=sampen(ryad1,m,r);
        k=k+i;
        p=p+1;
        entropymas(p)=e(m);
        ryad1=[];
    end;
    global mide;
    mide=sum(entropymas)/length(entropymas);
    set(handles.edit3,'String',num2str(mide));
    set(handles.text7,'String','- Sample Entropy');
else
    messageString=['Заповніть коректно всі поля вхідних параметрів!'];
    msgbox(messageString,'');
end;


% --- Executes when user attempts to close figure1.
function figure1_CloseRequestFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: delete(hObject) closes the figure
delete(hObject);
global ryad
global entropymas;
global mide;
mide=0;
ryad=[];
entropymas=[];

% --------------------------------------------------------------------
function Permen_Callback(hObject, eventdata, handles)
% hObject    handle to Permen (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%Нужно включить permbutton
global ryad;
[m,n]=size(ryad);
if (m==0) || (n==0)
    messageString=['Завантажте дані!'];
    msgbox(messageString,'');
else
    s=get(handles.edit2,'Visible');
    if s(2)=='f'
        set(handles.edit1,'Visible','on'); % значення для m
        set(handles.edit2,'Visible','on'); % значенян для r
        set(handles.edit2,'String','1');
        set(handles.edit4,'Visible','on'); % значення для ширини вікна
        set(handles.edit4,'String',num2str(n));
        set(handles.edit5,'Visible','on'); % значення для зміщення
        set(handles.text3,'Visible','on'); % m=
        set(handles.text4,'Visible','on'); % L=
        set(handles.text4,'String','L=');
        set(handles.text9,'Visible','on');  % Початкова ширина вікна
        set(handles.text10,'Visible','on'); % Крок зміщення вікна
        set(handles.permbutton,'Visible','on');
        set(handles.permbutton,'String','Обрахувати Permutation entropy');
    else
        set(handles.edit1,'Visible','on'); % значення для m
        set(handles.text3,'Visible','on'); % m=
        set(handles.edit1,'String','');
        set(handles.edit2,'String','1');
        set(handles.edit3,'String','');
        set(handles.edit4,'String',num2str(n));
        set(handles.edit5,'String','1');
        set(handles.text4,'String','L=');
        set(handles.permbutton,'Visible','on');
        set(handles.permbutton,'String','Обрахувати Permutation entropy');
        set(handles.aprbutton,'Visible','off');
        set(handles.samplebutton,'Visible','off');
        set(handles.tsbutton,'Visible','off');
    end;
end;

% --- Executes on button press in permbutton.
function permbutton_Callback(hObject, eventdata, handles)
% hObject    handle to permbutton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global ryad;
[kk,n]=size(ryad);
m=str2num(get(handles.edit1,'String'));
r=str2num(get(handles.edit2,'String'));
vikno=str2num(get(handles.edit4,'String'));
i=str2num(get(handles.edit5,'String'));
q=0;
if size(m)==[0,0]
   q=q+1;
end;
if size(r)==[0,0]
   q=q+1;
end;
if size(vikno)==[0,0]
    q=q+1;
end;
if vikno>n
    q=q+1;
end;
if size(i)==[0,0]
    q=q+1;
end;
if (q==0)
    global entropymas;
    entropymas=zeros(0,0);
    k=1;
    p=0;
    while (k+vikno-1)<=n
        ryad1=ryad(k:k+vikno-1);
        [e]=permen(ryad1,m,r);
        k=k+i;
        p=p+1;
        entropymas(p)=e;
        ryad1=[];
    end;
    global mide;
    mide=sum(entropymas)/length(entropymas);  
    set(handles.edit3,'String',num2str(mide));
    set(handles.text7,'String','- Permutation Entropy');
else
    messageString=['Заповніть коректно всі поля вхідних параметрів!'];
    msgbox(messageString,'');
end;


% --------------------------------------------------------------------
function grafik_Callback(hObject, eventdata, handles)
% hObject    handle to grafik (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function vrgrafik_Callback(hObject, eventdata, handles)
% hObject    handle to vrgrafik (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global ryad;
if size(ryad)==[0,0]
    messageString=['Завантажте ряд!'];
    msgbox(messageString,'');
else
    set(figure,'WindowButtonDownFcn',@WindowButtonDownFcn);
    plot(ryad,'k-');
end;

% --------------------------------------------------------------------
function degrafik_Callback(hObject, eventdata, handles)
% hObject    handle to degrafik (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global entropymas;
global mide;
if size(entropymas)==[0,0]
    messageString=['Спочатку зробіть обрахунки!'];
    msgbox(messageString,'');
else
    set(figure,'WindowButtonDownFcn',@WindowButtonDownFcn);
    plot(entropymas,'k');
    hold on;
    [m,n]=size(entropymas);
    x=[1:n];
    y=0;
    y(1:n)=mide;
    plot(x,y,'k--');
end;


% --- 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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
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 edit5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit5 (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



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


% --------------------------------------------------------------------
function TSentropy_Callback(hObject, eventdata, handles)
% hObject    handle to TSentropy (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%Нужно включить permbutton----------------------------------------------
global ryad;
[m,n]=size(ryad);
if (m==0) || (n==0)
    messageString=['Завантажте дані!'];
    msgbox(messageString,'');
else
    s=get(handles.edit2,'Visible');
    if s(2)=='f'
        set(handles.edit2,'Visible','on'); % значення для r
        set(handles.edit2,'String','1');
        set(handles.edit4,'Visible','on'); % значення для ширини вікна
        set(handles.edit4,'String',num2str(n));
        set(handles.edit5,'Visible','on'); % значення для зміщення
        set(handles.text4,'Visible','on'); % r=
        set(handles.text4,'String','q=');
        set(handles.text9,'Visible','on');  % Початкова ширина вікна    
        set(handles.text10,'Visible','on'); % Крок зміщення вікна
        set(handles.tsbutton,'Visible','on');
        set(handles.tsbutton,'String','Обрахувати Tsallis entropy');    
    else
        set(handles.edit1,'String','');
        set(handles.edit1,'Visible','off');
        set(handles.edit2,'String','');
        set(handles.edit2,'String','1');
        set(handles.edit3,'String','');
        set(handles.edit4,'String',num2str(n));
        set(handles.edit5,'String','1');
        set(handles.text3,'Visible','off');
        set(handles.text4,'String','q=');
        set(handles.tsbutton,'Visible','on');
        set(handles.tsbutton,'String','Обрахувати Tsallis entropy');
        set(handles.samplebutton,'Visible','off');
        set(handles.permbutton,'Visible','off');
        set(handles.aprbutton,'Visible','off');
    end;
end;
%--------------------------------------------------------------------------

% --- Executes on button press in tsbutton.
function tsbutton_Callback(hObject, eventdata, handles)
% hObject    handle to tsbutton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global ryad;
[kk,n]=size(ryad);
qparam=str2num(get(handles.edit2,'String'));
vikno=str2num(get(handles.edit4,'String'));
i=str2num(get(handles.edit5,'String'));
q=0;
if size(qparam)==[0,0]
    q=q+1;
end;
if size(vikno)==[0,0]
    q=q+1;
end;
if vikno>n
    q=q+1;
end;
if size(i)==[0,0]
    q=q+1;
end;
if (q==0)
    global entropymas;
    entropymas=zeros(0,0);
    k=1;
    p=0;
    while (k+vikno-1)<=n
        ryad1=ryad(k:k+vikno-1);
        e=TSentropy(ryad1,qparam);
        k=k+i;
        p=p+1;
        entropymas(p)=e;
        ryad1=[];
    end;
    global mide;
    mide=sum(entropymas)/length(entropymas);
    set(handles.edit3,'String',num2str(mide));
    set(handles.text7,'String','- Tsallis Entropy');
else
    messageString=['Заповніть коректно всі поля вхідних параметрів!'];
    msgbox(messageString,'');
end;


% --------------------------------------------------------------------
function normgrafik_Callback(hObject, eventdata, handles)
% hObject    handle to normgrafik (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global entropymas;
global mide;
if size(entropymas)==[0,0]
    messageString=['Спочатку зробіть обрахунки!'];
    msgbox(messageString,'');
else
    set(figure,'WindowButtonDownFcn',@WindowButtonDownFcn);
    entropymas_norm=entropymas;
    minimum=min(entropymas_norm);
    entropymas_norm=entropymas_norm-minimum;
    entropymas_norm=entropymas_norm/max(entropymas_norm);
    plot(entropymas_norm);
end;


% --------------------------------------------------------------------
function DegSave_Callback(hObject, eventdata, handles)
% hObject    handle to DegSave (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function NormSave_Callback(hObject, eventdata, handles)
% hObject    handle to NormSave (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global entropymas;
global mide;
if size(entropymas)==[0,0]
    messageString=['Спочатку зробіть обрахунки!'];
    msgbox(messageString,'');
else
    set(figure,'WindowButtonDownFcn',@WindowButtonDownFcn);
    entropymas_norm=entropymas;
    minimum=min(entropymas_norm);
    entropymas_norm=entropymas_norm-minimum;
    entropymas_norm=entropymas_norm/max(entropymas_norm);
    plot(entropymas_norm);
end;
