space boundary conditions. If the electric field is specified in one medium, the
ID: 2249469 • Letter: S
Question
space boundary conditions. If the electric field is specified in one medium, the corresponding field across the boundary can be calculated. In this project, you will assume that medium "1" is a dielectric or free space. The boundary is assumed to be the plane z= 0 with E, the electric field in the region z >= 0 and E2, the field in the region z 0. Furthermore, assume the electric field in region 1, is given as Ei-5a -2ay +3a, You are to create Matlab user-defined function(s) that you will use to find E2 in the other medium The inputs are the Ei that is given above, the relative permittivities, erl and er2 and the conductivities. The user should be prompted to enter the values of both the relative permittivities and conductivities Finally, write a script/program you will use to run the functions to calculate Ez - E2n E2t The program should also display the results. Make sure you test your program for all the 3 distinct cases discussed in class. Hint: Review Example MATLAB 5.2, page 209-210. Textbook.Explanation / Answer
clc
%prompt user for input materials
disp('Enter the relative permittivity in the region z > 0 ');
er1 = input('>');
if isempty(er1); er1 = 1;
elseif er1 < 1; er1 = 1;
end
disp('Enter the relative permittivity in the region z < 0 ');
er2 = input('If permittivity is infinite, input value as -1 >');
disp('Enter the conductivity in the region z > 0 ');
sig1 = input('>');
disp('Enter the conductivity in the region z < 0 ');
sig2 = input('If conductivity is infinite, input value as -1 >');
if er2 > 1;
%when medium 2 is dielectric
disp('Enter the electric field in side 1 in the form [Ex Ey Ez]');
E1 = input('>');
E1n = E1(3)*[0 0 1]; %normal direction is +z
E2n = E1n*er1/er2; %e-field boundary condition for normal component
E1t= E1 - E1n; %tangential component of E1
E2t = E1t; %e-field boundary condition for tangential component
E2 = E2t + E2n;
elseif sig2 == -1;
%when medium 2 is conductor
disp('Enter the electric field in side 1 in the form [Ex Ey Ez]');
e0 = 8.85419*10^-12;
E1 = input('>');
E2n = sig2/(er1*e0); %e-field boundary condition for normal component
E2t = 0; %e-field boundary condition for tangential component
E2 = E2t + E2n;
elseif er2 == 1;
%when medium 2 is free space
disp('Enter the electric field in side 1 in the form [Ex Ey Ez]');
e0 = 8.85419*10^-12;
E1 = input('>');
E2n = sig2/(e0); %e-field boundary condition for normal component
E2t = 0; %e-field boundary condition for tangential component
E2 = E2t + E2n;
else
disp('Invalid specification, please retry ');
end
%Display results
fprintf('The electric fields are');
fprintf(' E1 = (%d, %d, %d) V/m', E1(1), E1(2), E1(3));
fprintf(' E2 = (%d, %d, %d) V/m', E2(1), E2(2), E2(3));
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.