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

% Last Modified by GUIDE v2.5 04-Mar-2013 21:06:59

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

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = SDOF_freq_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 during object creation, after setting all properties.
function Stiffness_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Stiffness (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 Stiffness_Callback(hObject, eventdata, handles)
% hObject    handle to Stiffness (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 Stiffness as text
%        str2double(get(hObject,'String')) returns contents of Stiffness as a double
pb_handles = findobj('Style','edit');
%
for i = 1:1 %1st handle is for 'New game' button
    set(pb_handles(i), 'String', '');  %clear all squares
    set(pb_handles(i), 'UserData', 0); %all squares are not busy
end
handles.Stiffness = get(hObject,'String');
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function Mass_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Mass (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 Mass_Callback(hObject, eventdata, handles)
% hObject    handle to Mass (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 Mass as text
%        str2double(get(hObject,'String')) returns contents of Mass as a double
pb_handles = findobj('Style','edit');
%
for i = 1:1 %1st handle is for 'New game' button
    set(pb_handles(i), 'String', '');  %clear all squares
    set(pb_handles(i), 'UserData', 0); %all squares are not busy
end
handles.Mass = get(hObject,'String');
guidata(hObject, handles);


% --- Executes during object creation, after setting all properties.
function Answer_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Answer (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 Answer_Callback(hObject, eventdata, handles)
% hObject    handle to Answer (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 Answer as text
%        str2double(get(hObject,'String')) returns contents of Answer as a double
%
stiff=str2num(handles.Stiffness);
%
mass=str2num(handles.Mass);
MassSelection=handles.listbox1;
StiffSelection=handles.listbox2;
%
if(MassSelection==2)  % lbm
    mass=mass/2.205;
end
if(MassSelection==3)  % slug
    mass=mass/0.068542;
end
if(MassSelection==4)  % lbf sec^2/in
    mass=mass/0.068542;
end
%
if(StiffSelection==2)  % N/mm
    stiff=stiff/0.001;
end
if(StiffSelection==3)  % lbf/ft
    stiff=stiff/0.068519;
end
if(StiffSelection==4)  % lbf/in
    stiff=stiff/0.0057099;
end
%
fn=sqrt(stiff/mass)/(2.*pi);
fns=num2str(fn);
set(handles.Answer,'String',fns);
%
pb_handles = findobj('Style','edit');
%
for i = 2:3 %1st handle is for 'New game' button
    set(pb_handles(i), 'Enable', 'inactive')  %clear all squares
end


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


% --- Executes on button press in Reset.
function Reset_Callback(hObject, eventdata, handles)
% hObject    handle to Reset (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
pb_handles = findobj('Style','edit');
%
for i = 1:3 %1st handle is for 'New game' button
    set(pb_handles(i), 'String', '');  %clear all squares
    set(pb_handles(i), 'UserData', 0); %all squares are not busy
end
for i = 2:3 %1st handle is for 'New game' button
    set(pb_handles(i), 'Enable', 'on');  %clear all squares
end


% --- 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
pb_handles = findobj('Style','edit');
for i = 1:1 %1st handle is for 'New game' button
    set(pb_handles(i), 'String', '');  %clear all squares
    set(pb_handles(i), 'UserData', 0); %all squares are not busy
end
handles.listbox1 = get(hObject,'value');
guidata(hObject, handles);


% --- Executes during object creation, after setting all properties.
function listbox2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox2 (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 listbox2.
function listbox2_Callback(hObject, eventdata, handles)
% hObject    handle to listbox2 (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 listbox2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from listbox2
pb_handles = findobj('Style','edit');
for i = 1:1 %1st handle is for 'New game' button
    set(pb_handles(i), 'String', ''); %clear all squares
    set(pb_handles(i), 'UserData', 0); %all squares are not busy
end
handles.listbox2 = get(hObject,'value');
guidata(hObject, handles);
