Menu

[Solved]Function Varargout Gui Varargin Gui Matlab Code Guifig Gui Creates New Gui Raises Existing Q37254492

function varargout = gui(varargin)

% GUI MATLAB code for gui.fig

% GUI, by itself, creates a new GUI or raises the existing

% singleton*.

%

% H = GUI returns the handle to a new GUI or the handle to

% the existing singleton*.

%

% GUI(‘CALLBACK’,hObject,eventData,handles,…) calls thelocal

% function named CALLBACK in GUI.M with the given inputarguments.

%

% GUI(‘Property’,’Value’,…) creates a new GUI or raisesthe

% existing singleton*. Starting from the left, property valuepairs are

% applied to the GUI before gui_OpeningFcn gets called. An

% unrecognized property name or invalid value makes propertyapplication

% stop. All inputs are passed to gui_OpeningFcn viavarargin.

%

% *See GUI Options on GUIDE’s Tools menu. Choose “GUI allowsonly one

% instance to run (singleton)”.

%

% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help gui

% Last Modified by GUIDE v2.5 15-Apr-2019 20:20:32

% Begin initialization code – DO NOT EDIT

gui_Singleton = 1;

gui_State = struct(‘gui_Name’, mfilename, …

‘gui_Singleton’, gui_Singleton, …

‘gui_OpeningFcn’, @gui_OpeningFcn, …

‘gui_OutputFcn’, @gui_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 gui is made visible.

function gui_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 ofMATLAB

% handles structure with handles and user data (see GUIDATA)

% varargin command line arguments to gui (see VARARGIN)

% Choose default command line output for gui

handles.output = hObject;

% Update handles structure

guidata(hObject, handles);

% UIWAIT makes gui wait for user response (see UIRESUME)

% uiwait(handles.figure1);

% — Outputs from this function are returned to the commandline.

function varargout = gui_OutputFcn(hObject, eventdata,handles)

% varargout cell array for returning output args (seeVARARGOUT);

% hObject handle to figure

% eventdata reserved – to be defined in a future version ofMATLAB

% handles structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure

varargout{1} = handles.output;

function massWheel_Callback(hObject, eventdata, handles)

% hObject handle to massWheel (see GCBO)

% eventdata reserved – to be defined in a future version ofMATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,’String’) returns contents of massWheel astext

% str2double(get(hObject,’String’)) returns contents ofmassWheel as a double

% — Executes during object creation, after setting allproperties.

function massWheel_CreateFcn(hObject, eventdata, handles)

% hObject handle to massWheel (see GCBO)

% eventdata reserved – to be defined in a future version ofMATLAB

% handles empty – handles not created until after all CreateFcnscalled

% Hint: edit controls usually have a white background onWindows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,’BackgroundColor’),get(0,’defaultUicontrolBackgroundColor’))

set(hObject,’BackgroundColor’,’white’);

end

function avgMass_Callback(hObject, eventdata, handles)

% hObject handle to avgMass (see GCBO)

% eventdata reserved – to be defined in a future version ofMATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,’String’) returns contents of avgMass astext

% str2double(get(hObject,’String’)) returns contents of avgMassas a double

% — Executes during object creation, after setting allproperties.

function avgMass_CreateFcn(hObject, eventdata, handles)

% hObject handle to avgMass (see GCBO)

% eventdata reserved – to be defined in a future version ofMATLAB

% handles empty – handles not created until after all CreateFcnscalled

% Hint: edit controls usually have a white background onWindows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,’BackgroundColor’),get(0,’defaultUicontrolBackgroundColor’))

set(hObject,’BackgroundColor’,’white’);

end

function numPodds_Callback(hObject, eventdata, handles)

% hObject handle to numPodds (see GCBO)

% eventdata reserved – to be defined in a future version ofMATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,’String’) returns contents of numPodds astext

% str2double(get(hObject,’String’)) returns contents of numPoddsas a double

% — Executes during object creation, after setting allproperties.

function numPodds_CreateFcn(hObject, eventdata, handles)

% hObject handle to numPodds (see GCBO)

% eventdata reserved – to be defined in a future version ofMATLAB

% handles empty – handles not created until after all CreateFcnscalled

% Hint: edit controls usually have a white background onWindows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,’BackgroundColor’),get(0,’defaultUicontrolBackgroundColor’))

set(hObject,’BackgroundColor’,’white’);

end

function maxCapacityPerPod_Callback(hObject, eventdata,handles)

% hObject handle to maxCapacityPerPod (see GCBO)

% eventdata reserved – to be defined in a future version ofMATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,’String’) returns contents ofmaxCapacityPerPod as text

% str2double(get(hObject,’String’)) returns contents ofmaxCapacityPerPod as a double

% — Executes during object creation, after setting allproperties.

function maxCapacityPerPod_CreateFcn(hObject, eventdata,handles)

% hObject handle to maxCapacityPerPod (see GCBO)

% eventdata reserved – to be defined in a future version ofMATLAB

% handles empty – handles not created until after all CreateFcnscalled

% Hint: edit controls usually have a white background onWindows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,’BackgroundColor’),get(0,’defaultUicontrolBackgroundColor’))

set(hObject,’BackgroundColor’,’white’);

end

function angularV_Callback(hObject, eventdata, handles)

% hObject handle to angularV (see GCBO)

% eventdata reserved – to be defined in a future version ofMATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,’String’) returns contents of angularV astext

% str2double(get(hObject,’String’)) returns contents of angularVas a double

% — Executes during object creation, after setting allproperties.

function angularV_CreateFcn(hObject, eventdata, handles)

% hObject handle to angularV (see GCBO)

% eventdata reserved – to be defined in a future version ofMATLAB

% handles empty – handles not created until after all CreateFcnscalled

% Hint: edit controls usually have a white background onWindows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,’BackgroundColor’),get(0,’defaultUicontrolBackgroundColor’))

set(hObject,’BackgroundColor’,’white’);

end

function motorType_Callback(hObject, eventdata, handles)

% hObject handle to motorType (see GCBO)

% eventdata reserved – to be defined in a future version ofMATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,’String’) returns contents of motorType astext

% str2double(get(hObject,’String’)) returns contents ofmotorType as a double

% — Executes during object creation, after setting allproperties.

function motorType_CreateFcn(hObject, eventdata, handles)

% hObject handle to motorType (see GCBO)

% eventdata reserved – to be defined in a future version ofMATLAB

% handles empty – handles not created until after all CreateFcnscalled

% Hint: edit controls usually have a white background onWindows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,’BackgroundColor’),get(0,’defaultUicontrolBackgroundColor’))

set(hObject,’BackgroundColor’,’white’);

end

function time_Callback(hObject, eventdata, handles)

% hObject handle to time (see GCBO)

% eventdata reserved – to be defined in a future version ofMATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,’String’) returns contents of time astext

% str2double(get(hObject,’String’)) returns contents of time asa double

% — Executes during object creation, after setting allproperties.

function time_CreateFcn(hObject, eventdata, handles)

% hObject handle to time (see GCBO)

% eventdata reserved – to be defined in a future version ofMATLAB

% handles empty – handles not created until after all CreateFcnscalled

% Hint: edit controls usually have a white background onWindows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,’BackgroundColor’),get(0,’defaultUicontrolBackgroundColor’))

set(hObject,’BackgroundColor’,’white’);

end

function radius_Callback(hObject, eventdata, handles)

% hObject handle to radius (see GCBO)

% eventdata reserved – to be defined in a future version ofMATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,’String’) returns contents of radius astext

% str2double(get(hObject,’String’)) returns contents of radiusas a double

% — Executes during object creation, after setting allproperties.

function radius_CreateFcn(hObject, eventdata, handles)

% hObject handle to radius (see GCBO)

% eventdata reserved – to be defined in a future version ofMATLAB

% handles empty – handles not created until after all CreateFcnscalled

% Hint: edit controls usually have a white background onWindows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,’BackgroundColor’),get(0,’defaultUicontrolBackgroundColor’))

set(hObject,’BackgroundColor’,’white’);

end

% — Executes on button press in pushbutton1.

function pushbutton1_Callback(hObject, eventdata, handles)

wheel.massWheel=get(handle.massWheel);

wheel.avgMass=get(handle.avgMass);

wheel.radius=get(handle.radius);

wheel.maxCapacityPerPod=get(handle.maxCapacityPerPod);

wheel.numPods=get(handle.numPods);

wheel.angularV=get(handle.angularV);

wheel.motorType=get(handle.motorType);

wheel.time=get(handle.time);

wheel.momentOfInertia=(wheel.massWheel+(wheel.avgMass*wheel.maxCapacityPerPod*wheel.numPods))*(wheel.radius^2);

wheel.angularMomentum=wheel.momentOfInertia*wheel.angularV;

wheel.rotationalKineticEnergy=0.5*wheel.momentOfInertia*(wheel.angularV^2);

wheel.rotationalWork=wheel.rotationalKineticEnergy;

wheel.PowerRequiredFromMotor=wheel.rotationalWork/wheel.time;

% hObject handle to pushbutton1 (see GCBO)

% eventdata reserved – to be defined in a future version ofMATLAB

% handles structure with handles and user data (see GUIDATA)

% — Executes on button press in pushbutton2.

function pushbutton2_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton2 (see GCBO)

% eventdata reserved – to be defined in a future version ofMATLAB

% handles structure with handles and user data (see GUIDATA)

ABOVE IS MY GUI code and below is what it looks like

PUBLISH FILE PLOTS APP3 EDITOR gui massWh avgMas radius maxCapacity nput value result nput value numPo angula motorTy input v

but when I plug in values to these text boxes and press caculateit return error as following:

The class handle has no Constant property or Static method named’massWheel’.

Error in gui>pushbutton1_Callback (line 264)

wheel.massWheel=get(handle.massWheel);

Error in gui_mainfcn (line 95)

feval(varargin{:});

Error in gui (line 42)

gui_mainfcn(gui_State, varargin{:});

Error inmatlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)gui(‘pushbutton1_Callback’,hObject,eventdata,guidata(hObject))

Error while evaluating UIControl Callback.

can anyone tells me why?

this is a matlab code.

PUBLISH FILE PLOTS APP3 EDITOR gui massWh avgMas radius maxCapacity nput value result nput value numPo angula motorTy input value input valu time. nput value input value ar 0 nout value calculate Show transcribed image text PUBLISH FILE PLOTS APP3 EDITOR gui massWh avgMas radius maxCapacity nput value result nput value numPo angula motorTy input value input valu time. nput value input value ar 0 nout value calculate

Expert Answer


Answer to function varargout = gui(varargin) % GUI MATLAB code for gui.fig % GUI, by itself, creates a new GUI or raises the exist… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *