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

📄 planewavegui.m

📁 This is the procedure for lab 1. This is a two-week lab. Prelab should be done BEFORE going to the l
💻 M
📖 第 1 页 / 共 4 页
字号:
            'FontName','Arial',...
            'FitHeightToText','off',...
            'EdgeColor','none',...
            'Position',[Text1_x+0.203+deltaX Text1_y+0.244+deltaY 0.25 0.05]);

        % Create textbox (relative to gamma +)
        annotation(CalcDetails,'textbox','String',{['\Gamma_+ = ',num2str(gammaTEsx(q),'%2.3g')]},...
            'FontSize',11,...
            'FontWeight','demi',...
            'Color',colors(q,:),...
            'FontName','Arial',...
            'FitHeightToText','off',...
            'EdgeColor','none',...
            'Position',[Text1_x-0.01+deltaX Text1_y+0.215+deltaY 0.25 0.05]);

        % Create ellipse
        annotation(CalcDetails,'ellipse','FaceColor',colors(q,:),...
            'Position',[Ell1_x+deltaX Ell1_y+deltaY 0.008 0.008],'Color',colors(q,:));

        % Create ellipse
        annotation(CalcDetails,'ellipse','FaceColor',colors(q,:),...
            'Position',[Ell2_x+deltaX Ell2_y+deltaY 0.008 0.008],'Color',colors(q,:));

        if TE_TM==1   % TE wave
            % Create textbox
            annotation(CalcDetails,'textbox','String',{['\epsilon_{r',num2str(q),'} = ',num2str(er(q),'%2.3g')],['\mu_{r',num2str(q),'} = ',num2str(mr(q),'%2.3g')],['\sigma_{',num2str(q),'} = ',num2str(sigma(q),'%2.3g'),' S/m']},...
                'FontSize',11,...
                'FontWeight','demi',...
                'Color',colors(q,:),...
                'FontName','Arial',...
                'FitHeightToText','off',...
                'EdgeColor','none',...
                'Position',[Text1_x+deltaX Text1_y+deltaY 0.2 0.2]);
        else
            % Create textbox
            annotation(CalcDetails,'textbox','String',{['\epsilon_{r',num2str(q),'} = ',num2str(er(q),'%2.3g')],['\mu_{r',num2str(q),'} = ',num2str(mr(q),'%2.3g')],['\sigma_{',num2str(q),'} = ',num2str(sigma(q),'%2.3g'),' S/m']},...
                'FontSize',11,...
                'FontWeight','demi',...
                'Color',colors(q,:),...
                'FontName','Arial',...
                'FitHeightToText','off',...
                'EdgeColor','none',...
                'Position',[Text1_x+deltaX Text1_y+deltaY 0.2 0.2]);
        end

        if TE_TM==1   % TE wave
            % Create textbox
            annotation(CalcDetails,'textbox',...
                'String',{['\eta_{TE} = ',num2str(zTE(q),'%2.3g'),' \Omega'],['\lambda = ',num2str(wl(q),'%2.3g'),' m'],['\beta = ',num2str(beta(q),'%2.3g'),' rad/m'],['\alpha = ',num2str(alfa(q),'%2.3g'),' Np/m']},...
                'FontWeight','demi',...
                'FontSize',11,...
                'Color',colors(q,:),...
                'FontName','Arial',...
                'FitHeightToText','on',...
                'EdgeColor','none',...
                'LineWidth',2,...
                'Position',[Text2_x+deltaX Text2_y+deltaY 0.2 0.2]);
        else
            % Create textbox
            annotation(CalcDetails,'textbox',...
                'String',{['\eta_{TM} = ',num2str(zTM(q),'%2.3g'),' \Omega'],['\lambda = ',num2str(wl(q),'%2.3g'),' m'],['\beta = ',num2str(beta(q),'%2.3g'),' rad/m'],['\alpha = ',num2str(alfa(q),'%2.3g'),' Np/m']},...
                'FontWeight','demi',...
                'FontSize',11,...
                'Color',colors(q,:),...
                'FontName','Arial',...
                'FitHeightToText','on',...
                'EdgeColor','none',...
                'LineWidth',2,...
                'Position',[Text2_x+deltaX Text2_y+deltaY 0.2 0.2]);
        end

    end

    % plot last layer
    if Nl<=Lim1   % change line in the figure
        deltaX=deltaX+deltaXfig;
        deltaY=0;
    elseif Nl<=Lim2
        if Nl==Lim1+1;
            deltaX=0;
        else
            deltaX=deltaX+deltaXfig;
        end
        deltaY=deltaYfig;
    elseif Nl<=Lim2+Lim1
        deltaX=deltaX+deltaXfig;
        deltaY=0;
    elseif Nl<=Lim2+Lim2
        if Nl==Lim1+1;
            deltaX=0;
        else
            deltaX=deltaX+deltaXfig;
        end
        deltaY=deltaYfig;
    end

    % Create line
    annotation(CalcDetails,'line',Line1_x+deltaX,Line1_y+deltaY,'Color',colors(Nl,:),'LineWidth',2);

    % Create line
    annotation(CalcDetails,'line',Line2_x+deltaX,Line2_y+deltaY,'Color',colors(Nl,:),'LineWidth',2);

    % Create textbox (relative to gamma +)
    annotation(CalcDetails,'textbox','String',{['\Gamma_+ = 0']},...
        'FontSize',11,...
        'FontWeight','demi',...
        'Color',colors(Nl,:),...
        'FontName','Arial',...
        'FitHeightToText','off',...
        'EdgeColor','none',...
        'Position',[Text1_x-0.01+deltaX Text1_y+0.215+deltaY 0.25 0.05]);

    %     % Create ellipse
    %     annotation(CalcDetails,'ellipse','FaceColor',colors(Nl,:),...
    %         'Position',[Ell1_x+deltaX Ell1_y+deltaY 0.008 0.008],'Color',colors(Nl,:));
    %
    %     % Create ellipse
    %     annotation(CalcDetails,'ellipse','FaceColor',colors(Nl,:),...
    %         'Position',[Ell2_x+deltaX Ell2_y+deltaY 0.008 0.008],'Color',colors(Nl,:));

    if TE_TM==1   % TE wave
        % Create textbox
        annotation(CalcDetails,'textbox','String',{['\epsilon_{r',num2str(Nl),'} = ',num2str(er(Nl),'%2.3g')],['\mu_{r',num2str(Nl),'} = ',num2str(mr(Nl),'%2.3g')],['\sigma_{',num2str(Nl),'} = ',num2str(sigma(Nl),'%2.3g'),' S/m']},...
            'FontSize',11,...
            'FontWeight','demi',...
            'Color',colors(Nl,:),...
            'FontName','Arial',...
            'FitHeightToText','off',...
            'EdgeColor','none',...
            'Position',[Text1_x+deltaX Text1_y+deltaY 0.2 0.2]);
    else
        % Create textbox
        annotation(CalcDetails,'textbox','String',{['\epsilon_{r',num2str(Nl),'} = ',num2str(er(Nl),'%2.3g')],['\mu_{r',num2str(Nl),'} = ',num2str(mr(Nl),'%2.3g')],['\sigma_{',num2str(Nl),'} = ',num2str(sigma(Nl),'%2.3g'),' S/m']},...
            'FontSize',11,...
            'FontWeight','demi',...
            'Color',colors(Nl,:),...
            'FontName','Arial',...
            'FitHeightToText','off',...
            'EdgeColor','none',...
            'Position',[Text1_x+deltaX Text1_y+deltaY 0.2 0.2]);
    end

    if TE_TM==1   % TE wave
        % Create textbox
        annotation(CalcDetails,'textbox',...
            'String',{['\eta_{TE} = ',num2str(zTE(Nl),'%2.3g'),' \Omega'],['\lambda = ',num2str(wl(Nl),'%2.3g'),' m'],['\beta = ',num2str(beta(Nl),'%2.3g'),' rad/m'],['\alpha = ',num2str(alfa(Nl),'%2.3g'),' Np/m']},...
            'FontWeight','demi',...
            'FontSize',11,...
            'Color',colors(Nl,:),...
            'FontName','Arial',...
            'FitHeightToText','on',...
            'EdgeColor','none',...
            'LineWidth',2,...
            'Position',[Text2_x+deltaX Text2_y+deltaY 0.2 0.2]);
    else
        % Create textbox
        annotation(CalcDetails,'textbox',...
            'String',{['\eta_{TM} = ',num2str(zTM(Nl),'%2.3g'),' \Omega'],['\lambda = ',num2str(wl(Nl),'%2.3g'),' m'],['\beta = ',num2str(beta(Nl),'%2.3g'),' rad/m'],['\alpha = ',num2str(alfa(Nl),'%2.3g'),' Np/m']},...
            'FontWeight','demi',...
            'FontSize',11,...
            'Color',colors(Nl,:),...
            'FontName','Arial',...
            'FitHeightToText','on',...
            'EdgeColor','none',...
            'LineWidth',2,...
            'Position',[Text2_x+deltaX Text2_y+deltaY 0.2 0.2]);
    end
    close(hdlg)   % close 'Working...' message
end
return


function [z,deltaz]=linIntegr(a,b,N);

% a = starting point
% b = ending point
% N = number of pooints

dz=(b-a)/N;

zp=a+dz*[0:N];   % get delta z
z=(zp(1:N)+zp(2:(N+1)))/2;   % get mean points where the function has to be evaluated

deltaz=diff(zp);
return


function out=sqrt2(in,what)

% The script accounts for the branch cut crossing

% in: complex number in input
% what: 0 --> ordinary material (real(in) & imag(in) must be > 0)
%       1 --> ordinary material (real(in) & imag(in) must be < 0)

if what==0
    I=find(imag(in)<0);
    out=in;
    out(I)=-out(I);
elseif what==1
    I=find(imag(in)>0);
    out=in;
    out(I)=-out(I);
end
return


% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

global risp
risp=0;


function edit7_Callback(hObject, eventdata, handles)
% hObject    handle to edit7 (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 edit7 as text
%        str2double(get(hObject,'String')) returns contents of edit7 as a double


% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit7 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in radiobutton1.
function radiobutton1_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton1


% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (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 popupmenu1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu1


% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

RealORAbs{1,1}='Real values';
RealORAbs{2,1}='Absolute values';
set(hObject,'String',RealORAbs)


% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu2 (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 popupmenu2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu2


% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu2 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

TE_TM{1,1}='TE wave';
TE_TM{2,1}='TM wave';
set(hObject,'String',TE_TM)


function edit9_Callback(hObject, eventdata, handles)
% hObject    handle to edit9 (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 edit9 as text
%        str2double(get(hObject,'String')) returns contents of edit9 as a double


% --- Executes during object creation, after setting all properties.
function edit9_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit9 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


function edit10_Callback(hObject, eventdata, handles)
% hObject    handle to edit10 (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 edit10 as text
%        str2double(get(hObject,'String')) returns contents of edit10 as a double


% --- Executes during object creation, after setting all properties.
function edit10_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit10 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in radiobutton2.
function radiobutton2_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton2


function res=CheckInputs(teta,freq,er,mr,sigma,Zlay,what,ev,fH,A0,yrange,zrange,ns,anim,RoA,TE_TM,Calc)

% The script receives all inputs from the GUI and checks if they are ok in
% order to allow the script to run properly

% if checks are ok, output 1
res=1;

% check if any of the fields is empty
if isempty(teta)|isempty(freq)|isempty(er)|isempty(mr)|isempty(sigma)|isempty(Zlay)|isempty(A0)|isempty(yrange)|isempty(zrange)|isempty(ns)
    errordlg('Please check that none of the input fields is empty','Input error');
    res=0;
    return
end

% limited angle of incidence
if teta>90||teta<-90
    errordlg('Please check field "Angle of incidence": the angle of incidence must be comprised between -90

⌨️ 快捷键说明

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