I need a help with a GUI i'm trying to create.

조회 수: 1 (최근 30일)
José Sanches
José Sanches 2017년 12월 10일
댓글: Walter Roberson 2017년 12월 11일
Hi everybody
I need some help with a GUI.
It seems to be very simple but it´s my first time so i'm a litle bit lost
starting with the error i get
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)InputUser('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
my GUI is quite simple... i think:
2 popup menus 2 edit boxes 21 check boxes and a pushup button (ok)
so i want to insert values in the edit boxes, select things in the popup menus and check out some boxes ( and use the values as flags)
I tryed to do this but i get the error up there. Is there anybody that can help me?
Thanks in advance
function varargout = InputUser(varargin)
% INPUTUSER MATLAB code for InputUser.fig
% INPUTUSER, by itself, creates a new INPUTUSER or raises the existing
% singleton*.
%
% H = INPUTUSER returns the handle to a new INPUTUSER or the handle to
% the existing singleton*.
%
% INPUTUSER('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in INPUTUSER.M with the given input arguments.
%
% INPUTUSER('Property','Value',...) creates a new INPUTUSER or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before InputUser_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to InputUser_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 InputUser
% Last Modified by GUIDE v2.5 10-Dec-2017 22:20:56
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @InputUser_OpeningFcn, ...
'gui_OutputFcn', @InputUser_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 InputUser is made visible.
function InputUser_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 InputUser (see VARARGIN)
% Choose default command line output for InputUser
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes InputUser wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = InputUser_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 pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
chckbox1 = get(handles.checkbox1,'value')
chckbox2 = get(handles.checkbox2,'value')
chckbox3 = get(handles.checkbox3,'value')
chckbox4 = get(handles.checkbox4,'value')
chckbox5 = get(handles.checkbox5,'value')
chckbox6 = get(handles.checkbox6,'value')
chckbox7 = get(handles.checkbox7,'value')
chckbox8 = get(handles.checkbox8,'value')
chckbox9 = get(handles.checkbox9,'value')
chckbox10 = get(handles.checkbox10,'value')
chckbox11 = get(handles.checkbox11,'value')
chckbox12 = get(handles.checkbox12,'value')
chckbox14 = get(handles.checkbox13,'value')
chckbox14 = get(handles.checkbox14,'value')
chckbox15 = get(handles.checkbox15,'value')
chckbox16 = get(handles.checkbox16,'value')
chckbox17 = get(handles.checkbox17,'value')
chckbox18 = get(handles.checkbox18,'value')
chckbox19 = get(handles.checkbox19,'value')
chckbox20 = get(handles.checkbox20,'value')
chckbox21 = get(handles.checkbox21,'value')
chckbox22 = get(handles.checkbox22,'value')
edt1 = get(handles.edit1,'value')
edt2 = get(handles.edit2,'value')
pop1 = get(handles.popupmenu1,'value')
pop2 = get(handles.popupmenu2,'value')
% --- Executes on button press in checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)
% hObject handle to checkbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fVSabs = get(handles.checkbox1,'Value');
% Hint: get(hObject,'Value') returns toggle state of checkbox1
% --- Executes on button press in checkbox2.
function checkbox2_Callback(hObject, eventdata, handles)
% hObject handle to checkbox2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fVStcm = get(handles.checkbox2,'Value');
% Hint: get(hObject,'Value') returns toggle state of checkbox2
% --- Executes on button press in checkbox3.
function checkbox3_Callback(hObject, eventdata, handles)
% hObject handle to checkbox3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fWSfl = get(handles.checkbox3,'Value');
% Hint: get(hObject,'Value') returns toggle state of checkbox3
% --- Executes on button press in checkbox4.
function checkbox4_Callback(hObject, eventdata, handles)
% hObject handle to checkbox4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fWSfr = get(handles.checkbox4,'Value');
% Hint: get(hObject,'Value') returns toggle state of checkbox4
% --- Executes on button press in checkbox5.
function checkbox5_Callback(hObject, eventdata, handles)
% hObject handle to checkbox5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fWSrl = get(handles.checkbox5,'Value');
% Hint: get(hObject,'Value') returns toggle state of checkbox5
% --- Executes on button press in checkbox6.
function checkbox6_Callback(hObject, eventdata, handles)
% hObject handle to checkbox6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fWSrr = get(handles.checkbox6,'Value');
% Hint: get(hObject,'Value') returns toggle state of checkbox6
% --- Executes on button press in checkbox7.
function checkbox7_Callback(hObject, eventdata, handles)
% hObject handle to checkbox7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fLonA = get(handles.checkbox7,'Value');
% Hint: get(hObject,'Value') returns toggle state of checkbox7
% --- Executes on button press in checkbox8.
function checkbox8_Callback(hObject, eventdata, handles)
% hObject handle to checkbox8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fLatA = get(handles.checkbox8,'Value');
% Hint: get(hObject,'Value') returns toggle state of checkbox8
% --- Executes on button press in checkbox9.
function checkbox9_Callback(hObject, eventdata, handles)
% hObject handle to checkbox9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fICT = get(handles.checkbox9,'Value');
% Hint: get(hObject,'Value') returns toggle state of checkbox9
% --- Executes on button press in checkbox10.
function checkbox10_Callback(hObject, eventdata, handles)
% hObject handle to checkbox10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fAT = get(handles.checkbox10,'Value');
% Hint: get(hObject,'Value') returns toggle state of checkbox10
% --- Executes on button press in checkbox11.
function checkbox11_Callback(hObject, eventdata, handles)
% hObject handle to checkbox11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fOdT = get(handles.checkbox11,'Value');
% Hint: get(hObject,'Value') returns toggle state of checkbox11
% --- Executes on button press in checkbox12.
function checkbox12_Callback(hObject, eventdata, handles)
% hObject handle to checkbox12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fABS = get(handles.checkbox12,'Value');
% Hint: get(hObject,'Value') returns toggle state of checkbox12
% --- Executes on button press in checkbox13.
function checkbox13_Callback(hObject, eventdata, handles)
% hObject handle to checkbox13 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fAYC = get(handles.checkbox13,'Value');
% Hint: get(hObject,'Value') returns toggle state of checkbox13
% --- Executes on button press in checkbox14.
function checkbox14_Callback(hObject, eventdata, handles)
% hObject handle to checkbox14 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fSC = get(handles.checkbox14,'Value');
% Hint: get(hObject,'Value') returns toggle state of checkbox14
% --- Executes on button press in checkbox15.
function checkbox15_Callback(hObject, eventdata, handles)
% hObject handle to checkbox15 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fTC = get(handles.checkbox15,'Value');
% Hint: get(hObject,'Value') returns toggle state of checkbox15
% --- Executes on button press in checkbox16.
function checkbox16_Callback(hObject, eventdata, handles)
% hObject handle to checkbox16 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fES = get(handles.checkbox16,'Value');
% Hint: get(hObject,'Value') returns toggle state of checkbox16
% --- Executes on button press in checkbox17.
function checkbox17_Callback(hObject, eventdata, handles)
% hObject handle to checkbox17 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fWRfl = get(handles.checkbox17,'Value');
% Hint: get(hObject,'Value') returns toggle state of checkbox17
% --- Executes on button press in checkbox18.
function checkbox18_Callback(hObject, eventdata, handles)
% hObject handle to checkbox18 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fWRfr = get(handles.checkbox18,'Value');
% Hint: get(hObject,'Value') returns toggle state of checkbox18
% --- Executes on button press in checkbox19.
function checkbox19_Callback(hObject, eventdata, handles)
% hObject handle to checkbox19 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fWRrl = get(handles.checkbox19,'Value');
% Hint: get(hObject,'Value') returns toggle state of checkbox19
% --- Executes on button press in checkbox20.
function checkbox20_Callback(hObject, eventdata, handles)
% hObject handle to checkbox20 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fWRrr = get(handles.checkbox20,'Value');
% Hint: get(hObject,'Value') returns toggle state of checkbox20
% --- Executes on button press in checkbox21.
function checkbox21_Callback(hObject, eventdata, handles)
% hObject handle to checkbox21 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fWR = get(handles.checkbox21,'Value');
% Hint: get(hObject,'Value') returns toggle state of checkbox21
% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
vpm2 = get(handles.popupmenu2,'Value'); %get currently selected option from menu
if vpm2 == 1
RCh=1
elseif vpm2 == 2
RCh=2
end
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu2 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu2
% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu2 (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 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)
vpm1 = get(handles.popupmenu1,'Value'); %get currently selected option from menu
if vpm1 == 1
RCh=1
elseif vpm1 == 2
RCh=2
end
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
% --- 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
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)
samplingtime = get(handles.edit1,'Value');
% 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 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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
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)
samplefreq = get(handles.edit2,'Value');
%get currently selected option from menu
% Hints: get(hObject,'String') returns contents of edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
  댓글 수: 6
José Sanches
José Sanches 2017년 12월 11일
편집: José Sanches 2017년 12월 11일
Can you please give me an example? Because I have already a script with everything I want to do ( i mean where I am going to use all the values from the check boxes and so). The thing is I just don't know how to save these values in an array so I can use them in my script. I know I am using these functions ( callbacks) wrong but I need some help to understand the concept. This can be very easy to you but it is my first time with this. Thanks

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by