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

% Last Modified by GUIDE v2.5 31-Dec-2018 17:22:37

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @bmi_OpeningFcn, ...
                   'gui_OutputFcn',  @bmi_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
dem end;

% --- Executes just before bmi is made visible.
function bmi_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 bmi (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

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



% --- Outputs from this function are returned to the command line.
function varargout = bmi_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 button press in vypocti.
function vypocti_Callback(hObject, eventdata, handles)
% hObject    handle to vypocti (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
hmotnost=str2num(get(handles.hmotnost,'String'));
vyska=str2num(get(handles.vyska,'String'));
BMI= vypocet_BMI(hmotnost,vyska);
if BMI==0
    set(handles.vysledek,'String','Zadejte znovu');
else 
    set(handles.vysledek,'String',BMI);
end
if BMI<=18.5 && BMI>0
    set(handles.vaha,'String','podvaha','Foregroundcolor','blue');
    set(handles.riz,'String','vysoká','Foregroundcolor',[0.64 0.08 0.18]);
elseif BMI>18.5 && BMI<=24.9
    set(handles.vaha,'String','norma','Foregroundcolor',[0.47 0.67 0.19]);
    set(handles.riz,'String','minimální','Foregroundcolor',[0.47 0.67 0.19]);
elseif BMI>=25 && BMI<=29.9
    set(handles.vaha,'String','nadváha','Foregroundcolor',[0.93 0.69 0.13]);  
    set(handles.riz,'String','nízká až lehce vyšší','Foregroundcolor',[0.93 0.69 0.13]);
elseif BMI>=30 && BMI<=34.9
    set(handles.vaha,'String','obezita 1. stupně','Foregroundcolor',[0.85 0.33 0.1]);
    set(handles.riz,'String','zvýšená','Foregroundcolor',[0.85 0.33 0.1]);
elseif BMI<=39.9 && BMI>=35
    set(handles.vaha,'String','obezita 2.stupně','Foregroundcolor','red');
    set(handles.riz,'String','vysoká','Foregroundcolor','red');
elseif BMI>=40
    set(handles.vaha,'String','obezita 3.stupně','Foregroundcolor',[0.64 0.08 0.18]);
    set(handles.riz,'String','vysoká','Foregroundcolor',[0.64 0.08 0.18]);
else 
    set(handles.vaha,'String','');
    set(handles.riz,'String','');
end

set(handles.hmotnost,'String','','Enable','off');
set(handles.vyska,'String','','Enable','off');
set(handles.vypocti,'Enable','off');
set(handles.znovu_vypocti,'Visible','on');
a = 'fft';
plot([1 2 3])
x = 'fft'
y = 'fastaread';
fft(x);





function hmotnost_Callback(hObject, eventdata, handles)
% hObject    handle to hmotnost (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 hmotnost as text
%        str2double(get(hObject,'String')) returns contents of hmotnost as a double
input = str2num(get(hObject,'String'));
if (isempty(input))
     set(hObject,'String','0');
end
guidata(hObject, handles);
h = get(handles.hmotnost,'String');
% disp(h);
v = get(handles.vyska,'String');
if ~isempty(v) && ~isempty(h)
    set(handles.souhlas,'Enable','on');
end


% --- Executes during object creation, after setting all properties.
function hmotnost_CreateFcn(hObject, eventdata, handles)
% hObject    handle to hmotnost (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 vyska_Callback(hObject, eventdata, handles)
% hObject    handle to vyska (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 vyska as text
%        str2double(get(hObject,'String')) returns contents of vyska as a double
% if ~get(hObject,'String')
%     set(handles.vypocti,'Enable','off');
% end
inpud = str2num(get(hObject,'String'));
if (isempty(inpud))
     set(hObject,'String','0');
end
guidata(hObject, handles);
h = get(handles.hmotnost,'String');
% disp(h);
v = get(handles.vyska,'String');
if ~isempty(v) && ~isempty(h)
    set(handles.souhlas,'Enable','on');
end

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

if get(handles.souhlas,'Value')
    if get(handles.hmotnost,'String')
        if get(handles.vyska,'String');
            set(handles.vypocti,'Enable','on');
        else
            set(handles.vypocti,'Enable','off');
        end
    end
end


% Hint: get(hObject,'Value') returns toggle state of souhlas


% --- Executes on button press in znovu_vypocti.
function znovu_vypocti_Callback(hObject, eventdata, handles)
% hObject    handle to znovu_vypocti (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.hmotnost,'Enable','on');
set(handles.vyska,'Enable','on');
set(hObject,'Visible','off');
set(handles.riz,'String','');
set(handles.vaha,'String','');
set(handles.vysledek,'String','');
set(handles.souhlas,'Value',0);
set(handles.souhlas,'Enable','off');
