📄 gui_findbeta.m
字号:
function varargout = gui_findbeta(varargin)% GUI_FINDBETA M-file for gui_findbeta.fig% GUI_FINDBETA, by itself, creates a new GUI_FINDBETA or raises the existing% singleton*.%% H = GUI_FINDBETA returns the handle to a new GUI_FINDBETA or the handle to% the existing singleton*.%% GUI_FINDBETA('Property','Value',...) creates a new GUI_FINDBETA using the% given property value pairs. Unrecognized properties are passed via% varargin to gui_findbeta_OpeningFcn. This calling syntax produces a% warning when there is an existing singleton*.%% GUI_FINDBETA('CALLBACK') and GUI_FINDBETA('CALLBACK',hObject,...) call the% local function named CALLBACK in GUI_FINDBETA.M with the given input% arguments.%% *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 gui_findbeta% Last Modified by GUIDE v2.5 11-Jun-2006 18:54:16% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @gui_findbeta_OpeningFcn, ... 'gui_OutputFcn', @gui_findbeta_OutputFcn, ... 'gui_LayoutFcn', [], ... 'gui_Callback', []);if nargin & isstr(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endif 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_findbeta is made visible.function gui_findbeta_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 unrecognized PropertyName/PropertyValue pairs from the% command line (see VARARGIN)if nargin > 3 handles.min_lambda_val = str2num(varargin{2}); handles.max_lambda_val = str2num(varargin{4}); handles.nLambda_val = str2num(varargin{6}); handles.min_beta_val = str2num(varargin{8}); handles.max_beta_val = str2num(varargin{10}); handles.tol = str2num(varargin{12}); handles.sm = str2num(varargin{14}); handles.bPlot = str2num(varargin{16}); handles.nStart_val = str2num(varargin{18}); set(handles.tol_edit, 'string', varargin{12}); set(handles.sm_text, 'string', varargin{14}); set(handles.slider1, 'value', str2num(varargin{14})); set(handles.checkbox1, 'value', str2num(varargin{16})); set(handles.uiNstart, 'string', varargin{18}); set(handles.uiMinLambda, 'string', num2str(str2num(varargin{2}))); set(handles.uiMaxLambda, 'string', num2str(str2num(varargin{4}))); set(handles.uiNLambda, 'string', num2str(str2num(varargin{6}))); set(handles.min_beta, 'string', varargin{8}); set(handles.max_beta, 'string', varargin{10}); if handles.nLambda_val > 1 show_range(handles) endend% Choose default command line output for gui_findbetahandles.output = hObject;% Update handles structureguidata(hObject, handles);% FigPos=get(0,'DefaultFigurePosition');% FigWidth=215;FigHeight=88;% if isempty(gcbf)% ScreenUnits=get(0,'Units');% set(0,'Units','points');% ScreenSize=get(0,'ScreenSize');% set(0,'Units',ScreenUnits);% % FigPos(1)=1/2*(ScreenSize(3)-FigWidth);% FigPos(2)=2/3*(ScreenSize(4)-FigHeight);% else% GCBFOldUnits = get(gcbf,'Units');% set(gcbf,'Units','points');% GCBFPos = get(gcbf,'Position');% set(gcbf,'Units',GCBFOldUnits);% FigPos(1:2) = [(GCBFPos(1) + GCBFPos(3) / 2) - FigWidth / 2, ...% (GCBFPos(2) + GCBFPos(4) / 2) - FigHeight / 2];% end% FigPos(3:4)=[FigWidth FigHeight];% set(hObject, 'position', FigPos);% UIWAIT makes gui_findbeta wait for user response (see UIRESUME)uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = gui_findbeta_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 structurevarargout{1} = handles.output;delete(handles.figure1);% --- Executes during object creation, after setting all properties.function uiMinLambda_CreateFcn(hObject, eventdata, handles)% hObject handle to uiMinLambda (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 set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction uiMinLambda_Callback(hObject, eventdata, handles)% hObject handle to uiMinLambda (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 uiMinLambda as text% str2double(get(hObject,'String')) returns contents of uiMinLambda as a doublex = str2double(get(hObject,'String'));if isnan(x) | x < 0 set(hObject, 'String', num2str(handles.min_lambda_val));else handles.min_lambda_val = x;endguidata(hObject, handles)% --- Executes during object creation, after setting all properties.function min_beta_CreateFcn(hObject, eventdata, handles)% hObject handle to min_beta (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 set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction min_beta_Callback(hObject, eventdata, handles)% hObject handle to min_beta (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 min_beta as text% str2double(get(hObject,'String')) returns contents of min_beta as a double[x, ok] = str2num(get(hObject,'String'));if ~ok set(hObject, 'String', num2str(handles.min_beta_val));else handles.min_beta_val = x;endguidata(hObject, handles)% --- Executes on button press in calc.function calc_Callback(hObject, eventdata, handles)% hObject handle to calc (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)if handles.min_beta_val >= handles.max_beta_val h = errordlg('Effective index range should be positive', 'Error'); set(h, 'windowstyle', 'modal'); waitfor(h); returnendif (handles.min_lambda_val > handles.max_lambda_val) & (handles.nLambda_val ~= 1) h = errordlg('Wavelength range should not be negative', 'Error'); set(h, 'windowstyle', 'modal'); waitfor(h); returnendif (handles.min_lambda_val <=0) h = errordlg('Wavelength should be positive', 'Error'); set(h, 'windowstyle', 'modal'); waitfor(h); returnendhandles.status = 0;guidata(hObject, handles);handles.output = guidata(gcbo);% Update handles structureguidata(hObject, handles);% Use UIRESUME instead of delete because the OutputFcn needs% to get the updated handles structure.uiresume(handles.figure1);% --- Executes during object creation, after setting all properties.function max_beta_CreateFcn(hObject, eventdata, handles)% hObject handle to max_beta (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 set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction max_beta_Callback(hObject, eventdata, handles)% hObject handle to max_beta (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 max_beta as text% str2double(get(hObject,'String')) returns contents of max_beta as% a double[x, ok] = str2num(get(hObject,'String'));if ~ok set(hObject, 'String', num2str(handles.max_beta_val));else handles.max_beta_val = x;endguidata(hObject, handles)function figure1_CloseRequestFcn(hObject, eventdata, handles)handles.status = -1; guidata(hObject, handles);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -