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

📄 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 页
字号:
function varargout = PlaneWaveGUI(varargin)
%
% function varargout = PLANEWAVEGUI(varargin)
%
%  The function PLANEWAVEGUI creates the Graphical User Interface for the
%  TE/TM wave propagation through multilayered structures. See the file
%  'Help.html' or click on the button 'Help' of the GUI for its use. 
%
% Copyright: Lorenzo Luini, DEI-Department of Electronics and Information,
%            Politecnico di Milano, Milano, Italy;
%            email: luini@elet.polimi.it
%
% Release: version 1.0, last update: 05-Oct-2007 10:00:00
%
% Remarks: the GUI has been created using GUIDE. It requires Matlab release
%          R2007a to run properly.

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @PlaneWaveGUI_OpeningFcn, ...
                   'gui_OutputFcn',  @PlaneWaveGUI_OutputFcn, ...
                   'gui_LayoutFcn',  @PlaneWaveGUI_LayoutFcn, ...
                   'gui_Callback',   []);
if nargin && ischar(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 PlaneWaveGUI is made visible.
function PlaneWaveGUI_OpeningFcn(hObject, eventdata, handles, varargin)

% Choose default command line output for PlaneWaveGUI
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% Run the script with default values after initialization

% Retrieve input data from the GUI
teta=get(handles.edit5);
teta=str2num(teta.String);

freq=get(handles.edit1);
freq=str2num(freq.String);

er=get(handles.edit2);
er=str2num(er.String);

mr=get(handles.edit3);
mr=str2num(mr.String);

sigma=get(handles.edit4);
sigma=str2num(sigma.String);

Zlay=get(handles.edit6);
Zlay=str2num(Zlay.String);
Zlay=[0 Zlay];

fH(1)=handles.axes1;
fH(2)=handles.axes4;
fH(3)=handles.axes5;
fH(4)=handles.axes6;

A0=get(handles.edit7);
A0=str2num(A0.String);

anim=get(handles.radiobutton1);
anim=anim.Value;

RealorAbs=get(handles.popupmenu1,'Value');
TETM=get(handles.popupmenu2,'Value');

zval=get(handles.edit9);
zval=str2num(zval.String);

nsam=get(handles.edit10);
nsam=str2num(nsam.String);

% Define an alias of the function
PlaneW=@PlaneWave_MultLayer;

% Check if input data are correct
ResInp=CheckInputs(teta,freq,er,mr,sigma,Zlay,3,0,fH,A0,zval,zval,nsam,anim,RealorAbs,TETM,0);

% If check is passed, run the code
if ResInp==1
    PlaneWave_MultLayer(teta,freq,er,mr,sigma,Zlay,3,0,fH,A0,zval,zval,nsam,anim,RealorAbs,TETM,0)
end


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



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


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (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 edit2_Callback(hObject, eventdata, handles)
% hObject    handle to edit2 (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 edit2 as text
%        str2double(get(hObject,'String')) returns contents of edit2 as a double


% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (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 edit3_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (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 edit3 as text
%        str2double(get(hObject,'String')) returns contents of edit3 as a double


% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (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 edit4_Callback(hObject, eventdata, handles)
% hObject    handle to edit4 (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 edit4 as text
%        str2double(get(hObject,'String')) returns contents of edit4 as a double


% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4 (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 edit5_Callback(hObject, eventdata, handles)
% hObject    handle to edit5 (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 edit5 as text
%        str2double(get(hObject,'String')) returns contents of edit5 as a double


% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit5 (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 edit6_Callback(hObject, eventdata, handles)
% hObject    handle to edit6 (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 edit6 as text
%        str2double(get(hObject,'String')) returns contents of edit6 as a double


% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit6 (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 pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Retrieve input data from the GUI
teta=get(handles.edit5);
teta=str2num(teta.String);

freq=get(handles.edit1);
freq=str2num(freq.String);

er=get(handles.edit2);
er=str2num(er.String);

mr=get(handles.edit3);
mr=str2num(mr.String);

sigma=get(handles.edit4);
sigma=str2num(sigma.String);

Zlay=get(handles.edit6);
Zlay=str2num(Zlay.String);
Zlay=[0 Zlay];

fH(1)=handles.axes1;
fH(2)=handles.axes4;
fH(3)=handles.axes5;
fH(4)=handles.axes6;

A0=get(handles.edit7);
A0=str2num(A0.String);

anim=get(handles.radiobutton1);
anim=anim.Value;

RealorAbs=get(handles.popupmenu1,'Value');
TETM=get(handles.popupmenu2,'Value');

zval=get(handles.edit9);
zval=str2num(zval.String);

nsam=get(handles.edit10);
nsam=str2num(nsam.String);

Calculations=get(handles.radiobutton2);
Calculations=Calculations.Value;

% Define an alias of the function
PlaneW=@PlaneWave_MultLayer;

% Check if input data are correct
ResInp=CheckInputs(teta,freq,er,mr,sigma,Zlay,3,0,fH,A0,zval,zval,nsam,anim,RealorAbs,TETM,Calculations);

% If check is passed, run the code
if ResInp==1
    PlaneWave_MultLayer(teta,freq,er,mr,sigma,Zlay,3,0,fH,A0,zval,zval,nsam,anim,RealorAbs,TETM,Calculations)
end

%%%%%%%%%%%%%%%%%%%%%%%%% USER DEFINED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%% Main function of the whole GUI %%%%%%%%%%%%%%%%%%%%%%
function PlaneWave_MultLayer(teta,freq,er,mr,sigma,Zlay,what,ev,fH,A0,yrange,zrange,ns,anim,RoA,TE_TM,Calc)
%
% function PlaneWave_MultLayer(teta,freq,er,mr,sigma,Zlay,what,ev,fH,A0,yrange,zrange,ns,anim,RoA,TE_TM,Calc)
%
% The function implements a TE/TM plane wave with multiple layers in the yz
% plane (not dependent on x). Respectively the electric and the magnetic
% fields are calculated. Both ordinary materials and metamaterials can
% be introduced. The temporal convention implemented is exp(j*omega*t):
% imaginary parts of the permittivity and/or of the permeability has to be
% negative: eps=eps0.*(epsr_real-j*epsr_imag)-j*sigma./omega (sigma is
% obiviously positive).
%
% INPUT
%   teta = angle between the propagation direction and the normal to the
%          y-axis [癩
%   freq = frequency [Hz]
%   er = vector of relative electric permittivity
%   mr = vector of relative magnetic permeability
%   sigma = vector of conductivity [S/m]
%   Zlay = vector of the z-ccordinates of the interfaces between materials;
%          the first element must always be 0 m [m]. Interfaces must be
%          defined incrementally negative.
%   fH = handles of the GUI axes on which results are plotted
%   A0 = amplitude of the incidente wave [V/m] (TE) or [A/m] (TM)
%   yrange/zrange = limits of the y/z axis [m]
%   ns = number of samples of each axis
%   anim = 1 --> animate field
%          0 --> do not animate field
%   RoA = 1 --> plot real values
%         2 --> plot absolute values
%   TE_TM = 1 --> TE wave
%           2 --> TM wave
%   what = it must be set to 3
%   ev = it must be set to 0
%
% By: L.Luini
% Release: 28.VIII.2007

%%%%%%%%%%%%%%%%%%%%%%%%%%%% LAYERS PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Additional option to be set inside the code
% last layer type: 1) indefinite dielectric or conductor --> 0
%                  2) PMC -->  1
%                  3) PEC --> -1
LastLay=0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

global CalcDetails
global risp
global Lim1
global Lim2

ym=yrange(1);
yM=yrange(2);
zm=zrange(1);
zM=zrange(2);

pushbutton2_Callback

Nl=length(er);   % number of layers

% environment
delta=(max([zM yM])-min([zm ym]))/ns;   % spatial sampling [m]
x=zeros(1,ns);
y=[ym:delta:yM];
z=[zm:delta:zM];

% wave numbers and reflection coefficients
v0=3e8;
mu0=pi*4e-7;

⌨️ 快捷键说明

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