📄 gui_field_plot.m
字号:
function varargout = gui_field_plot(varargin)
% GUI_FIELD_PLOT M-file for gui_field_plot.fig
% GUI_FIELD_PLOT, by itself, creates a new GUI_FIELD_PLOT or raises the existing
% singleton*.
%
% H = GUI_FIELD_PLOT returns the handle to a new GUI_FIELD_PLOT or the handle to
% the existing singleton*.
%
% GUI_FIELD_PLOT('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI_FIELD_PLOT.M with the given input arguments.
%
% GUI_FIELD_PLOT('Property','Value',...) creates a new GUI_FIELD_PLOT or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before gui_field_plot_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to gui_field_plot_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 gui_field_plot
% Last Modified by GUIDE v2.5 14-Jun-2006 17:32:39
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @gui_field_plot_OpeningFcn, ...
'gui_OutputFcn', @gui_field_plot_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(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_field_plot is made visible.
function gui_field_plot_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 gui_field_plot (see VARARGIN)
% Choose default command line output for gui_field_plot
handles.xmin = str2num(varargin{2});
handles.xmax = str2num(varargin{4});
handles.ymin = str2num(varargin{6});
handles.ymax = str2num(varargin{8});
handles.sComp = varargin{10};
handles.pointsx = str2num(varargin{12});
pointsy = round(handles.pointsx/(handles.xmax - handles.xmin)*(handles.ymax - handles.ymin));
handles.pointsy = pointsy;
set(handles.uiPointsY, 'string', num2str(handles.pointsy));
set(handles.uiXmin, 'string', num2str(str2num(varargin{2}),'%0.3g'));
set(handles.uiXmax, 'string', num2str(str2num(varargin{4}),'%0.3g'));
set(handles.uiYmin, 'string', num2str(str2num(varargin{6}),'%0.3g'));
set(handles.uiYmax, 'string', num2str(str2num(varargin{8}),'%0.3g'));
comps = {'Ex', 'Ey', 'Ez', 'Hx', 'Hy', 'Hz', 'Sz'};
valComp = find(strcmp(comps, varargin{10}));
set(handles.uiComp, 'value', valComp);
set(handles.uiPointsX, 'string', varargin{12});
recent = varargin{16};
handles.oGeom = varargin{18};
handles.oGd = varargin{20};
handles.strClass = varargin{22};
set(handles.uiSym, 'string', ['Class: ' handles.strClass]);
handles.recent = [];
s = [];
ind = 2;
while ind < size(recent,1)-1
[dummy, rem] = strtok(recent(ind,:));
[dummy, rem] = strtok(rem);
lambda = str2double(strtok(rem));
ind = ind + 1;
while recent(ind,1) ~= '_'
[dummy, rem] = strtok(recent(ind,:));
[neff, dummy] = strtok(rem);
neff = str2double(neff);
handles.recent(end+1).lambda = lambda;
handles.recent(end).neff = neff;
str = ['Wavelength = ' num2str(lambda) ', Neff = ' num2str(neff)];
s = strvcat(s, str);
ind = ind + 1;
end
ind = ind + 2;
end
if isempty(handles.recent)
lambda = 0;
neff = 0;
set(handles.uiRecent, 'visible', 'off');
else
set(handles.uiRecent, 'visible', 'on');
set(handles.uiRecent, 'string', s);
lambda = handles.recent(1).lambda;
neff = handles.recent(1).neff;
end
set(handles.uiLambda, 'string', num2str(lambda))
set(handles.uiNeff, 'string', num2str(neff, '%0.8g'))
handles.lambda = lambda;
handles.neff = neff;
handles.output = guidata(hObject);
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes gui_field_plot wait for user response (see UIRESUME)
uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = gui_field_plot_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;
delete(handles.figure1);
% --- Executes during object creation, after setting all properties.
function uiComp_CreateFcn(hObject, eventdata, handles)
% hObject handle to uiComp (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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in uiComp.
function uiComp_Callback(hObject, eventdata, handles)
% hObject handle to uiComp (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns uiComp contents as cell array
% contents{get(hObject,'Value')} returns selected item from uiComp
% --- Executes during object creation, after setting all properties.
function uiXmin_CreateFcn(hObject, eventdata, handles)
% hObject handle to uiXmin (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'));
end
function uiXmin_Callback(hObject, eventdata, handles)
% hObject handle to uiXmin (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 uiXmin as text
% str2double(get(hObject,'String')) returns contents of uiXmin as a double
[val, ok] = str2num(get(handles.uiXmin, 'string'));
if ~ok
set(handles.uiXmin, 'string', num2str(handles.xmin, '%0.3g'));
else
handles.xmin = val;
end
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function uiXmax_CreateFcn(hObject, eventdata, handles)
% hObject handle to uiXmax (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'));
end
function uiXmax_Callback(hObject, eventdata, handles)
% hObject handle to uiXmax (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 uiXmax as text
% str2double(get(hObject,'String')) returns contents of uiXmax as a double
[val, ok] = str2num(get(handles.uiXmax, 'string'));
if ~ok
set(handles.uiXmax, 'string', num2str(handles.xmax, '%0.3g'));
else
handles.xmax = val;
end
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function uiYmin_CreateFcn(hObject, eventdata, handles)
% hObject handle to uiYmin (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'));
end
function uiYmin_Callback(hObject, eventdata, handles)
% hObject handle to uiYmin (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 uiYmin as text
% str2double(get(hObject,'String')) returns contents of uiYmin as a double
[val, ok] = str2num(get(handles.uiYmin, 'string'));
if ~ok
set(handles.uiYmin, 'string', num2str(handles.ymin, '%0.3g'));
else
handles.ymin = val;
end
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function uiYmax_CreateFcn(hObject, eventdata, handles)
% hObject handle to uiYmax (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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -