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

📄 show_results.m

📁 利用电磁场的源激发方法来计算光子晶体波导例如光子晶体光纤
💻 M
字号:
function varargout = show_results(varargin)
% SHOW_RESULTS M-file for show_results.fig
%      SHOW_RESULTS, by itself, creates a new SHOW_RESULTS or raises the existing
%      singleton*.
%
%      H = SHOW_RESULTS returns the handle to a new SHOW_RESULTS or the handle to
%      the existing singleton*.
%
%      SHOW_RESULTS('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in SHOW_RESULTS.M with the given input arguments.
%
%      SHOW_RESULTS('Property','Value',...) creates a new SHOW_RESULTS or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before show_results_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to show_results_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 show_results

% Last Modified by GUIDE v2.5 26-Oct-2005 17:20:05

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
    'gui_Singleton',  gui_Singleton, ...
    'gui_OpeningFcn', @show_results_OpeningFcn, ...
    'gui_OutputFcn',  @show_results_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 show_results is made visible.
function show_results_OpeningFcn(hObject, eventdata, handles, varargin)
global sResults
% 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 show_results (see VARARGIN)

% Choose default command line output for show_results
handles.hToggle = varargin{4};
if length(varargin) == 4
    set(handles.listbox1, 'string', sResults);
    handles.output = handles;
    guidata(hObject, handles);
    return
end

vBeta = str2num(varargin{6});
vErr = str2num(varargin{8});
f = -round(log10(str2num(varargin{10})));
lambda = varargin{12};
spc = repmat(' ', 1, round(max(15-f, 1)*1.35));
sResults = strvcat(sResults, ['Wavelength = ' num2str(lambda) ' [m]']);
for ind = 1:length(vErr)
    sResults = strvcat(sResults, [num2str(ind) '               ' num2str(vBeta(ind), ['%0.' num2str(f) 'f']) spc num2str(vErr(ind))]);
end
sResults = strvcat(sResults, repmat('_', 1, 28), ' ');
set(handles.listbox1, 'string', sResults);
handles.output = handles;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes show_results wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = show_results_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;


% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox 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 listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject    handle to listbox1 (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 listbox1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from listbox1


function uiClear_Callback(hObject, eventdata, handles)
global sResults
sResults = sResults(1,:);
set(handles.listbox1, 'string', sResults);
f = findobj('name', 'Set Parameters');
close(f)
guidata(hObject, handles);


function uiToBase_Callback(hObject, eventdata, handles)
recent = get(handles.listbox1, 'string');
out = parse_recent(recent);
if ~isempty(out)
    assignin('base', 'SMTout', out)
    disp('Results exported to variable: SMTout')
end

function uiToFile_Callback(hObject, eventdata, handles)
recent = get(handles.listbox1, 'string');
[FileName, PathName, FilterIndex] = uiputfile({'*.xls', 'Excel Worksheet (*.xls)'; ...
    '*.txt','Text File (*.txt)'}, 'Save as', 'modes.xls');
fn = [PathName FileName];
switch FilterIndex
    case 1
        out = parse_recent(recent);
        mOut = [out.lambda];
        mOut = [mOut; [out.neff]];
        mOut = [mOut; [out.err]].';
        [s, m] = xlswrite(fn, {'Wavelength', 'Eff. Index', 'CC Error'}, 'Mode Effective Indices');
        [s, m] = xlswrite(fn, mOut, 'Mode Effective Indices', 'A2');
    case 2
        fid = fopen(fn, 'w');
        for ind = 1:size(recent, 1)
            fprintf(fid, recent(ind,:));
            fprintf(fid, '\n');
        end
        fclose(fid);
end

function figure1_CloseRequestFcn(hObject, eventdata, handles)
set(handles.hToggle, 'value', 0)
delete(handles.figure1)

⌨️ 快捷键说明

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