我创建了一个 GUI 函数,如下所示。我想要做的是把这个 GUI 放在一个循环中,这样我就可以将它用于不同的元素。对于输出,我有两个 6 x 1 的向量。我想要做的是,当我选择不同的单选按钮并将不同的值放入 GUI 的编辑文本中时,将结果保存在输出的不同位置矢量取决于单选按钮。我试图给 GUI 一个标题作为输入。
提前致谢。
function varargout = distributedloads(varargin)
% DISTRIBUTEDLOADS MATLAB code for distributedloads.fig
% DISTRIBUTEDLOADS, by itself, creates a new DISTRIBUTEDLOADS or raises the existing
% singleton*.
%
% H = DISTRIBUTEDLOADS returns the handle to a new DISTRIBUTEDLOADS or the handle to
% the existing singleton*.
%
% DISTRIBUTEDLOADS('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DISTRIBUTEDLOADS.M with the given input arguments.
%
% DISTRIBUTEDLOADS('Property','Value',...) creates a new DISTRIBUTEDLOADS or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before distributedloads_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to distributedloads_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 distributedloads
% Last Modified by GUIDE v2.5 28-Feb-2016 14:52:56
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @distributedloads_OpeningFcn, ...
'gui_OutputFcn', @distributedloads_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 distributedloads is made visible.
function distributedloads_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 distributedloads (see VARARGIN)
imshow('disloads.png')
% Choose default command line output for distributedloads
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes distributedloads wait for user response (see UIRESUME)
uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = distributedloads_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)
varargout = str2double(handles.DATA.EL);
function ELNUM_Callback(hObject, eventdata, handles)
% hObject handle to ELNUM (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 ELNUM as text
% str2double(get(hObject,'String')) returns contents of ELNUM as a double
EL = get(hObject , 'String');
handles.DATA.EL = EL;
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function ELNUM_CreateFcn(hObject, eventdata, handles)
% hObject handle to ELNUM (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 LOADVAL_Callback(hObject, eventdata, handles)
% hObject handle to LOADVAL (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 LOADVAL as text
% str2double(get(hObject,'String')) returns contents of LOADVAL as a double
Load = get(hObject , 'String');
handles.DATA.Load = Load;
guidata(hObject , handles)
% --- Executes during object creation, after setting all properties.
function LOADVAL_CreateFcn(hObject, eventdata, handles)
% hObject handle to LOADVAL (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 CONFIRM.
function CONFIRM_Callback(hObject, eventdata, handles)
% hObject handle to CONFIRM (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
delete(handles.figure1)
% --------------------------------------------------------------------
function buttongroup_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to buttongroup (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Type = get(hObject , 'selectedObject');
handles.DATA.Type = Type;
guidata(hObject , handles)