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

📄 gui_field_plot.m

📁 利用电磁场的源激发方法来计算光子晶体波导例如光子晶体光纤
💻 M
📖 第 1 页 / 共 2 页
字号:
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function uiYmax_Callback(hObject, eventdata, handles)
% hObject    handle to uiYmax (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 uiYmax as text
%        str2double(get(hObject,'String')) returns contents of uiYmax as a double
[val, ok] = str2num(get(handles.uiYmax, 'string'));
if ~ok
    set(handles.uiYmax, 'string', num2str(handles.ymax, '%0.3g'));
else
    handles.ymax = val;
end

guidata(hObject, handles);


% --- Executes during object creation, after setting all properties.
function uiPointsX_CreateFcn(hObject, eventdata, handles)
% hObject    handle to uiPointsX (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 uiPointsX_Callback(hObject, eventdata, handles)
% hObject    handle to uiPointsX (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 uiPointsX as text
%        str2double(get(hObject,'String')) returns contents of uiPointsX as a double
[val, ok] = str2num(get(handles.uiPointsX, 'string'));
if ~ok
    set(handles.uiPointsX, 'string', num2str(handles.pointsx));
else
    handles.pointsx = val;
    pointsy = round(handles.pointsx/(handles.xmax - handles.xmin)*(handles.ymax - handles.ymin));
    handles.pointsy = pointsy;
    set(handles.uiPointsY, 'string', num2str(handles.pointsy));
end
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function uiPointsY_CreateFcn(hObject, eventdata, handles)
% hObject    handle to uiPointsY (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 uiPointsY_Callback(hObject, eventdata, handles)
% hObject    handle to uiPointsY (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 uiPointsY as text
%        str2double(get(hObject,'String')) returns contents of uiPointsY as a double
[val, ok] = str2num(get(handles.uiPointsY, 'string'));
if ~ok
    set(handles.uiPointsY, 'string', num2str(handles.pointsy));
else
    handles.pointsy = val;
    pointsx = round(handles.pointsy/(handles.ymax - handles.ymin)*(handles.xmax - handles.xmin));
    handles.pointsx = pointsx;
    set(handles.uiPointsX, 'string', num2str(handles.pointsx));
end
guidata(hObject, handles);


% --- Executes on button press in uiPlot.
function uiPlot_Callback(hObject, eventdata, handles)
% hObject    handle to uiPlot (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
comps = {'Ex', 'Ey', 'Ez', 'Hx', 'Hy', 'Hz', 'Sz'};
sComp = comps{get(handles.uiComp, 'value')};
k0 = 2*pi/handles.lambda;
neff = handles.neff;
oGeom = handles.oGeom;
oGd = handles.oGd;
h = msgbox('Solving for source amplitudes...', 'SMTgui', 'help');
strClass = get(handles.uiSym, 'string');
strClass = strClass(end-1:end);
if strcmp(strClass, 'ne')
    strClass = 'none';
end
handles.strClass = strClass;
if handles.strClass(1) ~= 'n'
    switch handles.strClass
        case 'p1'
            handles.strClass = 'p5';
        case 'p2'
            handles.strClass = 'p6';
        case 'p7'
            handles.strClass = 'p3';
        case 'p8'
            handles.strClass = 'p4';
    end
    oGeom = cut_pos(oGd, oGeom, handles.strClass);
end
delete(h);
[L, vSolution] = smt_solve(neff, oGd, oGeom, k0);
pointsx = handles.pointsx;
pointsy = handles.pointsy;
xmin = handles.xmin;
ymin = handles.ymin;
xmax = handles.xmax;
ymax = handles.ymax;
if pointsx == 1
    vX = mean([xmin, xmax]);
else
    vX = linspace(xmin, xmax, pointsx);
end
if pointsy == 1
    vY = mean([ymin, ymax]);
else
    vY = linspace(ymin, ymax, pointsy);
end
mF = calc_field(vSolution, oGeom, oGd, k0, neff, sComp, handles.strClass, vX, vY);
if ~isnan(mF)
    gui_show_mode('mF', mF, 'oGd', oGd, 'vX', vX, 'vY', vY);
end
%uiresume(handles.figure1);


% --- Executes on button press in uiCancel.
function uiCancel_Callback(hObject, eventdata, handles)
% hObject    handle to uiCancel (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(hObject);
guidata(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 uiLambda_CreateFcn(hObject, eventdata, handles)
% hObject    handle to uiLambda (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 uiLambda_Callback(hObject, eventdata, handles)
% hObject    handle to uiLambda (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 uiLambda as text
%        str2double(get(hObject,'String')) returns contents of uiLambda as a double
[val, ok] = str2num(get(handles.uiLambda, 'string'));
if ~ok
    set(handles.uiLambda, 'string', num2str(handles.lambda));
else
    handles.lambda = val;
end
guidata(hObject, handles);


% --- Executes during object creation, after setting all properties.
function uiNeff_CreateFcn(hObject, eventdata, handles)
% hObject    handle to uiNeff (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 uiNeff_Callback(hObject, eventdata, handles)
% hObject    handle to uiNeff (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 uiNeff as text
%        str2double(get(hObject,'String')) returns contents of uiNeff as a double
[val, ok] = str2num(get(handles.uiNeff, 'string'));
if ~ok
    set(handles.uiNeff, 'string', num2str(handles.neff, '%0.8g'));
else
    handles.neff = val;
end
guidata(hObject, handles);


% --- Executes during object creation, after setting all properties.
function uiRecent_CreateFcn(hObject, eventdata, handles)
% hObject    handle to uiRecent (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 uiRecent.
function uiRecent_Callback(hObject, eventdata, handles)
% hObject    handle to uiRecent (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 uiRecent contents as cell array
%        contents{get(hObject,'Value')} returns selected item from uiRecent
sel = get(hObject, 'value');
handles.lambda = handles.recent(sel).lambda;
set(handles.uiLambda, 'string', num2str(handles.lambda));
handles.neff = handles.recent(sel).neff;
set(handles.uiNeff, 'string', num2str(handles.neff, '%0.8g'));
guidata(hObject, handles);


function figure1_CloseRequestFcn(hObject, eventdata, handles)
guidata(hObject, handles);
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);
uiresume(handles.figure1);

⌨️ 快捷键说明

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