⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gui_symmetry.m

📁 利用电磁场的源激发方法来计算光子晶体波导例如光子晶体光纤
💻 M
字号:
function varargout = gui_Symmetry(varargin)% GUI_SYMMETRY M-file for gui_Symmetry.fig%      GUI_SYMMETRY, by itself, creates a new GUI_SYMMETRY or raises the existing%      singleton*.%%      H = GUI_SYMMETRY returns the handle to a new GUI_SYMMETRY or the handle to%      the existing singleton*.%%      GUI_SYMMETRY('CALLBACK',hObject,eventData,handles,...) calls the local%      function named CALLBACK in GUI_SYMMETRY.M with the given input arguments.%%      GUI_SYMMETRY('Property','Value',...) creates a new GUI_SYMMETRY or raises the%      existing singleton*.  Starting from the left, property value pairs are%      applied to the GUI before gui_Symmetry_OpeningFunction gets called.  An%      unrecognized property name or invalid value makes property application%      stop.  All inputs are passed to gui_Symmetry_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_Symmetry% Last Modified by GUIDE v2.5 30-Mar-2006 09:38:30% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name',       mfilename, ...    'gui_Singleton',  gui_Singleton, ...    'gui_OpeningFcn', @gui_Symmetry_OpeningFcn, ...    'gui_OutputFcn',  @gui_Symmetry_OutputFcn, ...    'gui_LayoutFcn',  [] , ...    'gui_Callback',   []);if nargin && ischar(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_Symmetry is made visible.function gui_Symmetry_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_Symmetry (see VARARGIN)% Choose default command line output for gui_Symmetryhandles.output = hObject;set(handles.uiPanelSym, 'SelectionChangeFcn',@uiPanel_Callback);set(handles.uiPanelSym, 'UserData', handles);handles.strClass = varargin{1};bFini = handles.strClass(1) == 'f';strButton = [handles.strClass 'Button'];if handles.strClass(1) ~= 'n';    draw_class(handles.strClass(2), bFini, handles.axes);endhButton = eval(['handles.' strButton]);set(handles.uiPanelSym, 'SelectedObject', hButton);% Update handles structureguidata(hObject, handles);% UIWAIT makes gui_Symmetry wait for user response (see UIRESUME)uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = gui_Symmetry_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 on button press in uiOK.function uiOK_Callback(hObject, eventdata, handles)% hObject    handle to uiOK (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)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);function figCloseRequest(hObject, eventdata, handles)guidata(hObject, handles);handles.output = guidata(gcbo);% Update handles structureguidata(hObject, handles);uiresume(handles.figure1);function uiPanel_Callback(source,eventdata)if eventdata.EventName ~= 'SelectionChanged'    returnendhandles = get(source, 'UserData');str = get(eventdata.NewValue,'String');bFini = (size(str, 1) == 2);if bFini    str = str(1,:);    str = str{:};endif str(1) == 'N'    handles.strClass = 'none';    guidata(gcf, handles);    cla(handles.axes);    returnenddraw_class(str(end), bFini, handles.axes);handles.strClass = ['p' str(end)];if bFini    handles.strClass(1) = 'f';endguidata(gcf, handles);function draw_class(class, bFini, hAxes)%axis equalaxis(hAxes, [-1 1 -1 1])axes(hAxes)claif bFini    vGreen = green_fun_vector(['f' class]);    [n, d] = rat(imag(log(vGreen)/pi), 1e-3);    for ind = 1:6        x1 = -cos(pi/3*ind)*0.95;        y1 = -sin(pi/3*ind)*0.95;        x2 = cos(pi/3*ind)*0.95;        y2 = sin(pi/3*ind)*0.95;        xt = cos(pi/3*(ind-1)+pi/6)*0.7;        yt = sin(pi/3*(ind-1)+pi/6)*0.7;        if ind <= 3            h = line([x1,x2], [y1,y2]);            set(h, 'color', 'k')        end        if n(ind) == 0            h = text(xt, yt, '1');            fixfonts(h, 13);            continue        end        if abs(n(ind)) == 1 & abs(d(ind)) == 1            h = text(xt, yt, '-1');            fixfonts(h, 13);            continue        end        if n(ind) < 0            n(ind) = - n(ind);            sMinus = '-';        else            sMinus = '';        end        if n(ind) == 1            sN = '';        else            sN = num2str(n(ind));        end        if d(ind) == 1            sD = '';        else            sD = ['/' num2str(d(ind))];        end        str = ['e^{' sMinus 'j' sN '\pi' sD '}'];        h = text(xt, yt, str);        fixfonts(h, 13);    end    returnendang = sym_angle(['p' class]);bFirstPEC = (class == '2') | (class == '4') | (class == '6') | (class == '8');bSecondPEC = (class == '2') | (class == '3') | (class == '6') | (class == '7');N = round(2*pi/ang);for ind = 0:(N-1)/2    x1 = -cos(ang*ind)*0.95;    y1 = -sin(ang*ind)*0.95;    x2 = cos(ang*ind)*0.95;    y2 = sin(ang*ind)*0.95;    h = line([x1,x2], [y1,y2]);    set(h, 'color', 'k')    if mod(ind, 2) == 0        if ~bFirstPEC            set(h, 'linestyle', ':');        end    else        if ~bSecondPEC            set(h, 'linestyle', ':');        end    endend

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -