- dialog for setting the random seed copyright 2009-2012 Blair Armstrong, Christine Watson, David Plaut This file is part of SOS SOS is free software: you can redistribute it and/or modify it for academic and non-commercial purposes under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. For commercial or for-profit uses, please contact the authors (sos@cnbc.cmu.edu). SOS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
0001 % - dialog for setting the random seed 0002 % 0003 % copyright 2009-2012 Blair Armstrong, Christine Watson, David Plaut 0004 % 0005 % This file is part of SOS 0006 % 0007 % SOS is free software: you can redistribute it and/or modify 0008 % it for academic and non-commercial purposes 0009 % under the terms of the GNU General Public License as published by 0010 % the Free Software Foundation, either version 3 of the License, or 0011 % (at your option) any later version. For commercial or for-profit 0012 % uses, please contact the authors (sos@cnbc.cmu.edu). 0013 % 0014 % SOS is distributed in the hope that it will be useful, 0015 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 % GNU General Public License for more details. 0018 0019 % You should have received a copy of the GNU General Public License 0020 % along with SOS (see COPYING.txt). 0021 % If not, see <http://www.gnu.org/licenses/>. 0022 0023 0024 function varargout = setSeed_Dialog(varargin) 0025 % SETSEED_DIALOG M-file for setSeed_Dialog.fig 0026 % SETSEED_DIALOG, by itself, creates a new SETSEED_DIALOG or raises the existing 0027 % singleton*. 0028 % 0029 % H = SETSEED_DIALOG returns the handle to a new SETSEED_DIALOG or the handle to 0030 % the existing singleton*. 0031 % 0032 % SETSEED_DIALOG('CALLBACK',hObject,eventData,handles,...) calls the local 0033 % function named CALLBACK in SETSEED_DIALOG.M with the given input arguments. 0034 % 0035 % SETSEED_DIALOG('Property','Value',...) creates a new SETSEED_DIALOG or raises the 0036 % existing singleton*. Starting from the left, property value pairs are 0037 % applied to the GUI before setSeed_Dialog_OpeningFcn gets called. An 0038 % unrecognized property name or invalid value makes property application 0039 % stop. All inputs are passed to setSeed_Dialog_OpeningFcn via varargin. 0040 % 0041 % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one 0042 % instance to run (singleton)". 0043 % 0044 % See also: GUIDE, GUIDATA, GUIHANDLES 0045 0046 % Edit the above text to modify the response to help setSeed_Dialog 0047 0048 % Last Modified by GUIDE v2.5 09-Sep-2010 17:39:01 0049 0050 % Begin initialization code - DO NOT EDIT 0051 gui_Singleton = 1; 0052 gui_State = struct('gui_Name', mfilename, ... 0053 'gui_Singleton', gui_Singleton, ... 0054 'gui_OpeningFcn', @setSeed_Dialog_OpeningFcn, ... 0055 'gui_OutputFcn', @setSeed_Dialog_OutputFcn, ... 0056 'gui_LayoutFcn', [] , ... 0057 'gui_Callback', []); 0058 if nargin && ischar(varargin{1}) 0059 gui_State.gui_Callback = str2func(varargin{1}); 0060 end 0061 0062 if nargout 0063 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); 0064 else 0065 gui_mainfcn(gui_State, varargin{:}); 0066 end 0067 % End initialization code - DO NOT EDIT 0068 0069 0070 0071 % --- Executes just before setSeed_Dialog is made visible. 0072 function setSeed_Dialog_OpeningFcn(hObject, eventdata, handles, varargin) 0073 % This function has no output args, see OutputFcn. 0074 % hObject handle to figure 0075 % eventdata reserved - to be defined in a future version of MATLAB 0076 % handles structure with handles and user data (see GUIDATA) 0077 % varargin command line arguments to setSeed_Dialog (see VARARGIN) 0078 0079 % Choose default command line output for setSeed_Dialog 0080 handles.output = hObject; 0081 0082 % Update handles structure 0083 guidata(hObject, handles); 0084 0085 % UIWAIT makes setSeed_Dialog wait for user response (see UIRESUME) 0086 % uiwait(handles.figure_setSeed); 0087 0088 0089 % --- Outputs from this function are returned to the command line. 0090 function varargout = setSeed_Dialog_OutputFcn(hObject, eventdata, handles) 0091 % varargout cell array for returning output args (see VARARGOUT); 0092 % hObject handle to figure 0093 % eventdata reserved - to be defined in a future version of MATLAB 0094 % handles structure with handles and user data (see GUIDATA) 0095 0096 % Get default command line output from handles structure 0097 varargout{1} = handles.output; 0098 0099 0100 % --- Executes on button press in pushbutton_setSeed. 0101 function pushbutton_setSeed_Callback(hObject, eventdata, handles) 0102 % hObject handle to pushbutton_setSeed (see GCBO) 0103 % eventdata reserved - to be defined in a future version of MATLAB 0104 % handles structure with handles and user data (see GUIDATA) 0105 0106 % validate the number of iterations to display 0107 0108 create = true; 0109 0110 seed = get(handles.edit_seed,'String'); 0111 0112 %check to make sure that the name is a valid variable name: 0113 valid = regexp(seed,'^(-)?[1-9]+[0-9]*$', 'once'); 0114 0115 0116 if isempty(valid) 0117 % name is not currently valid, tell the user. 0118 msgbox('Seed must be an integer',... 0119 'Invalid seed!'); 0120 create = false; 0121 end 0122 0123 % if the first variable passed, proceed to check the second 0124 if create == true 0125 0126 command = ['setSeed(',seed,');']; 0127 0128 verbosePrint(['Executing command: ','''',command,''''],'setSeed_Dialog_Set'); 0129 evalin('base',command); 0130 0131 close(handles.figure_setSeed); 0132 end 0133 0134 0135 0136 0137 function edit_seed_Callback(hObject, eventdata, handles) 0138 % hObject handle to edit_seed (see GCBO) 0139 % eventdata reserved - to be defined in a future version of MATLAB 0140 % handles structure with handles and user data (see GUIDATA) 0141 0142 % Hints: get(hObject,'String') returns contents of edit_seed as text 0143 % str2double(get(hObject,'String')) returns contents of edit_seed as a double 0144 seed = get(hObject,'String'); 0145 0146 % validate that the seed is an integer 0147 valid = regexp(seed,'^(-)?[1-9]+[0-9]*$', 'once'); 0148 0149 0150 if isempty(valid) 0151 % name is not currently valid, tell the user. 0152 msgbox('Seed must be an integer',... 0153 'Invalid seed!'); 0154 end 0155 0156 % --- Executes during object creation, after setting all properties. 0157 function edit_seed_CreateFcn(hObject, eventdata, handles) 0158 % hObject handle to edit_seed (see GCBO) 0159 % eventdata reserved - to be defined in a future version of MATLAB 0160 % handles empty - handles not created until after all CreateFcns called 0161 0162 % Hint: edit controls usually have a white background on Windows. 0163 % See ISPC and COMPUTER. 0164 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 0165 set(hObject,'BackgroundColor','white'); 0166 end