0% found this document useful (0 votes)
29 views1 page

TM & Te

This document contains MATLAB code to calculate the electric and magnetic fields for TE and TM modes in a waveguide. It prompts the user for parameters like mode numbers and dimensions, then calculates wavenumbers and fields for the specified mode using common waveguide equations.

Uploaded by

harshit goel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views1 page

TM & Te

This document contains MATLAB code to calculate the electric and magnetic fields for TE and TM modes in a waveguide. It prompts the user for parameters like mode numbers and dimensions, then calculates wavenumbers and fields for the specified mode using common waveguide equations.

Uploaded by

harshit goel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

clc;

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

You might also like