TM & Te
TM & Te
close all;
clear all;
q=input('Choose 1 for TE and 2 for TM');
if q==1
m = input('Enter the value for m:');
n = input('Enter the value for n:');
elseif q==2
m = input('Enter the value for m:');
n = input('Enter the value for n:');
end
a = input('Enter dimension across x axis:');
b=a/2;
Eo=2;
Ho=4;
pi=3.14;
kx=m*pi/a;
ky=n*pi/b;
er=2.2;
mr=1;
c=3e8;
f=input('Enter frequency in GHz:');
omega=2*pi*f
B = omega*(sqrt(mr*er));
Bc = sqrt(kx.^2+ky.^2);
Bz = sqrt(B.^2-Bc.^2);
fc=((0.5*pi*c)/sqrt(mr*er))*sqrt(kx^2+ky^2)
if q==1
Zte=377*(sqrt(mr/er))/(sqrt(1-(fc/f)^2))
x=0:0.1:a;
y=0:0.05:b;
Ex= Eo.*cos(kx.*x).*sin(ky.*y);
Ey=Eo.*sin(kx*x).*sin(ky*y);
Hx =Ho.*sin(kx.*x).*cos(ky.*y);
Hy=Ho.*cos(kx.*x).*sin(n*pi.*y);
Hz =cos(kx.*x).*cos(ky.*y);
subplot(2,1,1)
plot3(x,y,Ex,'-r',x,y,Ey,'-m')
xlabel('x--->')
ylabel('y--->')
zlabel('Electric field')
elseif q==2
Ztm=377*(sqrt(mr/er))*(sqrt(1-(fc/f)^2));
x=0:0.1:a;
y=0:0.05:b;
Hz=0;
z=0;
Ex = cos(kx.*x).*sin(ky.*y);
Ey = sin(kx.*x).*cos(ky.*y);
Ez = sin(kx.*x).*sin(ky.*y);
Hx = sin(kx.*x).*cos(ky.*y);
Hy = cos(kx.*x).*sin(ky.*y);
subplot(2,1,1)
plot3(x,y,Ex,'-r',x,y,Ey,'-m')
xlabel('x--->')
ylabel('y--->')
zlabel('Electric field')
end