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

📄 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 页
字号:
            ylabel('z [m]')
            set(gca,'YDir','normal')
            axis square
            hold on;
            for q=2:Nl
                h=line([y(1) y(end)],[Zlay(q) Zlay(q)]);
                set(h,'Color','k','LineWidth',1)
            end
            colorbar
            hold off;
            if TE_TM==1
                title('Progressive field E_x')
            elseif TE_TM==2
                title('Progressive field H_x')
            end

            axes(fH(3))
            imagesc(y,z,abs(FieldR))
            xlabel('y [m]')
            ylabel('z [m]')
            set(gca,'YDir','normal')
            axis square
            hold on;
            for q=2:Nl
                h=line([y(1) y(end)],[Zlay(q) Zlay(q)]);
                set(h,'Color','k','LineWidth',1)
            end
            colorbar
            hold off;
            if TE_TM==1
                title('Regressive field E_x')
            elseif TE_TM==2
                title('Regressive field H_x')
            end

            % movie
            tv=0;
            dT=1./(32.*freq);
            risp=1;
            while risp==1
                tv=tv+dT;
                axes(fH(4))
                % plot the field for a fixed value of y (center of the
                % axis) ABS
                plot(z,abs(EtTE(:,round(ns/2)).*exp(j.*omega.*tv)),'LineWidth',1.5)
                axis([z(1) z(end) 0 2*A0])
                hold on;
                for q=2:Nl
                    h=line([Zlay(q) Zlay(q)],[-2*A0 2*A0]);
                    set(h,'Color','k','LineWidth',1)
                end
                xlabel('z [m]')
                if TE_TM==1
                    ylabel('abs(E) [V/m]')
                    title('E_x field for y = 0 m')
                elseif TE_TM==2
                    ylabel('abs(H) [A/m]')
                    title('H_x field for y = 0 m')
                end
                set(gca,'XDir','Reverse')
                hold off;
            end
        else   % static fields
            FieldT=EtTE;
            FieldP=EsTE_progr_only;
            FieldR=EsTE_regr_only;

            axes(fH(1))
            imagesc(y,z,abs(FieldT))
            xlabel('y [m]')
            ylabel('z [m]')
            set(gca,'YDir','normal')
            axis square
            hold on;
            for q=2:Nl
                h=line([y(1) y(end)],[Zlay(q) Zlay(q)]);
                set(h,'Color','k','LineWidth',1)
            end
            colorbar
            hold off;
            if TE_TM==1
                title('Total field E_x')
            elseif TE_TM==2
                title('Total field H_x')
            end

            axes(fH(2))
            imagesc(y,z,abs(FieldP))
            xlabel('y [m]')
            ylabel('z [m]')
            set(gca,'YDir','normal')
            axis square
            hold on;
            for q=2:Nl
                h=line([y(1) y(end)],[Zlay(q) Zlay(q)]);
                set(h,'Color','k','LineWidth',1)
            end
            colorbar
            hold off;
            if TE_TM==1
                title('Progressive field E_x')
            elseif TE_TM==2
                title('Progressive field H_x')
            end

            axes(fH(3))
            imagesc(y,z,abs(FieldR))
            xlabel('y [m]')
            ylabel('z [m]')
            set(gca,'YDir','normal')
            axis square
            hold on;
            for q=2:Nl
                h=line([y(1) y(end)],[Zlay(q) Zlay(q)]);
                set(h,'Color','k','LineWidth',1)
            end
            colorbar
            hold off;
            if TE_TM==1
                title('Regressive field E_x')
            elseif TE_TM==2
                title('Regressive field H_x')
            end

            axes(fH(4))
            % plot the field for a fixed value of y (center of the axis)
            % ABS
            plot(z,abs(EtTE(:,round(ns/2))),'LineWidth',1.5)
            axis([z(1) z(end) 0 2*A0])
            hold on;
            for q=2:Nl
                h=line([Zlay(q) Zlay(q)],[-2*A0 2*A0]);
                set(h,'Color','k','LineWidth',1)
            end
            xlabel('z [m]')
            if TE_TM==1
                ylabel('abs(E) [V/m]')
                title('E_x field for y = 0 m')
            elseif TE_TM==2
                ylabel('abs(H) [A/m]')
                title('H_x field for y = 0 m')
            end
            set(gca,'XDir','Reverse')
            hold off;
        end
    end
end

% plot calculation details if requested
if Calc==1
    % plot info about the layers (beta, alfa, wavelength, gamma)
    %%%%%%% PLOT PARAMETERS (TO MOVE BOXES EASILY) %%%%%%%%
    deltaXfig=0.233;
    deltaYfig=-0.42;
    Line1_x=[0.035 0.27];
    Line1_y=[0.84 0.84];
    Line2_x=[0.035 0.27];
    Line2_y=[0.73 0.73];
    Ell1_x=0.266;
    Ell1_y=0.836;
    Ell2_x=0.266;
    Ell2_y=0.726;
    Text1_x=0.045;
    Text1_y=0.64;
    Text2_x=0.045;
    Text2_y=0.525;
    
    % the first variable indicates the maximum number of line sections
    % plotted on the same line; the second one indicates the maximum number
    % of line sections plotted on the same figure
    Lim1=3;
    Lim2=6;
    
    % colors of the line sections
    colors=['b';'k';'r';'b';'k';'r';'b';'k';'r';'b';'k';'r'];
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    % plot 'Working' message
    hdlg=helpdlg('Working...please wait','Information');

    % set the figure according to the screen resolution
    scrsz=get(0,'ScreenSize');

    % Old vector for 'Position' option of the figure opened below, with 'Units','pixels'  --> [120 1 1000 650]
    CalcDetails1=figure('Name','Calculation details','Units','normalized','Position',[0.05 0.1 0.95 0.8]);

    % begin plot on the first figure
    CalcDetails=CalcDetails1;
    
    % title
    annotation(CalcDetails1,'textbox',...
        'String',{'Calculation details: transmission line model'},...
        'HorizontalAlignment','center',...
        'FontSize',16,...
        'FontName','Verdana',...
        'FitHeightToText','off',...
        'LineStyle','none',...
        'Position',[0.2116 0.895 0.5915 0.09662]);

    % Create line
    annotation(CalcDetails1,'line',Line1_x,Line1_y,'Color',colors(1,:),'LineWidth',2);

    % Create line
    annotation(CalcDetails1,'line',Line2_x,Line2_y,'Color',colors(1,:),'LineWidth',2);

    % Create line (layers discriminator)
    annotation(CalcDetails1,'line',[Line1_x(2) Line1_x(2)],[Line1_y(2) Line2_y(2)],'Color',colors(1,:),'LineWidth',2,'LineStyle','--');

    % Create line (relative to gamma -)
    annotation(CalcDetails1,'line',[Line1_x(2) Line1_x(2)]-0.01,[Line1_y(2)-0.05 Line2_y(2)]+0.1,'Color',colors(1,:),'LineWidth',2);

    % Create line (relative to gamma +)
    annotation(CalcDetails1,'line',[Line1_x(2) Line1_x(2)]+0.01,[Line1_y(2)-0.08 Line2_y(2)]+0.1,'Color',colors(2,:),'LineWidth',2);

    % Create textbox (relative to gamma -)
    annotation(CalcDetails1,'textbox','String',{['\Gamma_- = ',num2str(gammaTEdx(1),'%2.3g')]},...
        'FontSize',11,...
        'FontWeight','demi',...
        'Color',colors(1,:),...
        'FontName','Arial',...
        'FitHeightToText','off',...
        'EdgeColor','none',...
        'Position',[Text1_x+0.203 Text1_y+0.244 0.25 0.05]);

    % Create ellipse
    annotation(CalcDetails1,'ellipse','FaceColor',colors(1,:),...
        'Position',[Ell1_x Ell1_y 0.008 0.008],'Color',colors(1,:));

    % Create ellipse
    annotation(CalcDetails1,'ellipse','FaceColor',colors(1,:),...
        'Position',[Ell2_x Ell2_y 0.008 0.008],'Color',colors(1,:));

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

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

    deltaX=0;
    for q=2:Nl-1
        if q<=Lim2   % in the first figure
            CalcDetails=CalcDetails1;
            if q<=Lim1   % first line in the figure
                deltaY=0;
                if q==1;
                    deltaX=0;
                else
                    deltaX=deltaX+deltaXfig;
                end
            else   % second line in the figure
                if q==Lim1+1;
                    deltaX=0;
                else
                    deltaX=deltaX+deltaXfig;
                end
                deltaY=deltaYfig;
            end
        else   % second figure
            if ~exist('CalcDetails2','var')
                CalcDetails2=figure('Name','Calculation details','Units','normalized','Position',[0.05 0.1 0.95 0.8]);
            end
            CalcDetails=CalcDetails2;
            if q<=Lim2+Lim1   % first line in the figure
                deltaY=0;
                if q==Lim2+1;
                    deltaX=0;
                else
                    deltaX=deltaX+deltaXfig;
                end
            else   % second line in the figure
                if q==Lim2+Lim1+1;
                    deltaX=0;
                else
                    deltaX=deltaX+deltaXfig;
                end
                deltaY=deltaYfig;
            end
        end

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

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

        % Create line
        annotation(CalcDetails,'line',[Line1_x(2) Line1_x(2)]+deltaX,[Line1_y(2) Line2_y(2)]+deltaY,'Color',colors(q,:),'LineWidth',2,'LineStyle','--');

        % Create line (relative to gamma -)
        annotation(CalcDetails,'line',[Line1_x(2) Line1_x(2)]+deltaX-0.01,[Line1_y(2)-0.05 Line2_y(2)]+deltaY+0.1,'Color',colors(q,:),'LineWidth',2);

        % Create line (relative to gamma +)
        %         if q==Lim1
        %             deltaXdiff=0-(Line1_x(2)-Line1_x(1));
        %             deltaYdiff=deltaYfig;
        %         else
        %             deltaXdiff=deltaX;
        %             deltaYdiff=deltaY;
        %         end

        if q<Lim2   % first figure
            CalcDetailsDiff=CalcDetails1;
            if q==Lim1
                deltaXdiff=0-(Line1_x(2)-Line1_x(1));
                deltaYdiff=deltaYfig;
            else
                deltaXdiff=deltaX;
                deltaYdiff=deltaY;
            end
        elseif q==Lim2
            if ~exist('CalcDetails2','var')
                CalcDetails2=figure('Name','Calculation details','Units','normalized','Position',[0.05 0.1 0.95 0.8]);
            end
            CalcDetailsDiff=CalcDetails2;
            deltaXdiff=0-(Line1_x(2)-Line1_x(1));
            deltaYdiff=0;
        else   % second figure
            CalcDetailsDiff=CalcDetails2;
            if q==Lim1+Lim2
                deltaXdiff=0-(Line1_x(2)-Line1_x(1));
                deltaYdiff=deltaYfig;
            else
                deltaXdiff=deltaX;
                deltaYdiff=deltaY;
            end
        end

        annotation(CalcDetailsDiff,'line',[Line1_x(2) Line1_x(2)]+deltaXdiff+0.01,[Line1_y(2)-0.08 Line2_y(2)]+deltaYdiff+0.1,'Color',colors(q+1,:),'LineWidth',2);

        % Create textbox (relative to gamma -)
        annotation(CalcDetails,'textbox','String',{['\Gamma_- = ',num2str(gammaTEdx(q),'%2.3g')]},...
            'FontSize',11,...
            'FontWeight','demi',...
            'Color',colors(q,:),...

⌨️ 快捷键说明

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