function varargout = moment(varargin)
% MOMENT MATLAB code for moment.fig
% MOMENT, by itself, creates a new MOMENT or raises the existing
% singleton*.
%
% H = MOMENT returns the handle to a new MOMENT or the handle to
% the existing singleton*.
%
% MOMENT('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MOMENT.M with the given input arguments.
%
% MOMENT('Property','Value',...) creates a new MOMENT or raises
% the existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before moment_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to moment_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 moment
% Last Modified by GUIDE v2.5 26-Jun-2016 19:18:43
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @moment_OpeningFcn, ...
'gui_OutputFcn', @moment_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 moment is made visible.
function moment_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 moment (see VARARGIN)
% Choose default command line output for moment
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
%initialize_gui(hObject, handles, false);
% UIWAIT makes moment wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = moment_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 mass1_CreateFcn(hObject, eventdata, handles)
% hObject handle to mass1 (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
function mass1_Callback(hObject, eventdata, handles)
% hObject handle to mass1 (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 mass1 as text
% str2double(get(hObject,'String')) returns contents of mass1 as a double
handles.mass1 = str2double(get(hObject, 'String'));
if isnan(mass)
set(hObject, 'String', 0);
errordlg('Input must be a number','Error');
end
% Save the new mass1 value
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function radiusb_CreateFcn(hObject, eventdata, handles)
% hObject handle to radiusb (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
function radiusb_Callback(hObject, eventdata, handles)
% hObject handle to radiusb (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 radiusb as text
% str2double(get(hObject,'String')) returns contents of radiusb as a double
handles.radiusb = str2double(get(hObject, 'String'));
if isnan(radius)
set(hObject, 'String', 0);
errordlg('Enter a number','Error');
end
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function radius2b_CreateFcn(hObject, eventdata, handles)
% hObject handle to radius2b (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 radius2b_Callback(hObject, eventdata, handles)
% hObject handle to radius2b (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 radius2b as text
% str2double(get(hObject,'String')) returns contents of radius2b as a double
handles.radius2b= str2double(get(hObject, 'String'));
if isnan(radius2)
set(hObject, 'String', 0);
errordlg('Input must be a number','Error');
end
% Save the new radius2b value
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function lengthb_CreateFcn(hObject, eventdata, handles)
% hObject handle to lengthb (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 lengthb_Callback(hObject, eventdata, handles)
% hObject handle to lengthb (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 lengthb as text
% str2double(get(hObject,'String')) returns contents of lengthb as a double
handles.lengthb= str2double(get(hObject, 'String'));
if isnan(length)
set(hObject, 'String', 0);
errordlg('Input must be a number','Error');
end
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function lenghtab_CreateFcn(hObject, eventdata, handles)
% hObject handle to lenghtab (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 lenghtab_Callback(hObject, eventdata, handles)
% hObject handle to lenghtab (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 lenghtab as text
% str2double(get(hObject,'String')) returns contents of lenghtab as a double
handles.lenghtab= str2double(get(hObject, 'String'));
if isnan(lenghta)
set(hObject, 'String', 0);
errordlg('Input must be a number','Error');
end
%
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function lenghtbb_CreateFcn(hObject, eventdata, handles)
% hObject handle to lenghtbb (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 lenghtbb_Callback(hObject, eventdata, handles)
% hObject handle to lenghtbb (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 lenghtbb as text
% str2double(get(hObject,'String')) returns contents of lenghtbb as a double
handles.lenghtbb = str2double(get(hObject, 'String'));
if isnan(lenghtb)
set(hObject, 'String', 0);
errordlg('Enter a number','Error');
end
% Save the new lenghtbb value
guidata(hObject,handles)
% --- 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
updateaxes(handles)
guidata(hObject,handles)
% --- 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 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)
hoop=handles.mass1*(handles.radiusb.^2);
hollow=0.5*handles.mass1*(handles.radiusb.^2+handles.cradius2b.^2);
disk=(1/12)*handles.mass1*(handles.radiusb.^.2);
rectangle=(1/12)*handles.mass1*(handles.lenght.^2+handles.langhtbb.^2);
thin_rod=(1/12)*handles.mass1*(handles.lenghtb.^2)
thin_rod_2=(1/3)*handles.mass1*(handles.lenghtb.^2);
sphere=(2/5)*handles.mass1*(handle.radiusb.^2)
shere_shell=(2/3)*handles.mass1*(handle.radiusb.^2)
switch str
case 'Hoop'
set(handles.Answer, 'String',hoop);
Related Question
MATLAB: Project help, I need to submit the project a gui tommorow but i keep on getting errors
gui
Best Answer