Docsity

MATLAB Script for Simulating Pressure Distribution in a 2D Waveguide - Prof. Robert McGoug, Assignments of Electrical and Electronics Engineering

Toggle sidebar
bg1
homework 10
problem 1
xp = 0:.025:1.5; % units of a
zp = 0:.01:1; % units of a^2/lambda
Nxo = length(xp);
Nzo = length(zp);
pressure = complex(zeros(length(xp), length(zp)), zeros(length(xp), length(zp)));
a = 2.5; b = 1.5 * a;
Nxs = 12 * 4; % 48
ix = 1:Nxs;
xsource(ix) = a / Nxs * (2 * (ix - Nxs/2) - 1);
Nys = 18 * 4;
iy = 1:Nys; % 72
ysource(iy) = b / Nys * (2 * (iy - Nys/2) - 1);
deltax = xsource(2) - xsource(1);
deltay = ysource(2) - ysource(1);
wavenum = 2 * pi; % normalized to lambda like the rest
for ixs = 1:Nxs,
for iys = 1:Nys,
for ixo = 1:Nxo,
for izo = 1:Nzo,
distance = sqrt((xsource(ixs) - a * xp(ixo))^2 + ysource(iys)^2 + (zp(izo) * a^2)^2);
pf3
pf4
pf5

Partial preview of the text

Download MATLAB Script for Simulating Pressure Distribution in a 2D Waveguide - Prof. Robert McGoug and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

homework 10 problem 1

xp = 0:.025:1.5; % units of a zp = 0:.01:1; % units of a^2/lambda Nxo = length(xp); Nzo = length(zp); pressure = complex(zeros(length(xp), length(zp)), zeros(length(xp), length(zp)));

a = 2.5; b = 1.5 * a; Nxs = 12 * 4; % 48 ix = 1:Nxs; xsource(ix) = a / Nxs * (2 * (ix - Nxs/2) - 1);

Nys = 18 * 4; iy = 1:Nys; % 72 ysource(iy) = b / Nys * (2 * (iy - Nys/2) - 1);

deltax = xsource(2) - xsource(1); deltay = ysource(2) - ysource(1); wavenum = 2 * pi; % normalized to lambda like the rest

for ixs = 1:Nxs, for iys = 1:Nys, for ixo = 1:Nxo, for izo = 1:Nzo, distance = sqrt((xsource(ixs) - a * xp(ixo))^2 + ysource(iys)^2 + (zp(izo) * a^2)^2);

pressure(ixo, izo) = pressure(ixo, izo) + deltax * deltay * exp(-j * wavenum * distance) / distance; end end end end

mesh(zp, xp, abs(pressure)/max(max(abs(pressure)))) ylabel('normalized lateral distance x (units of half width ''a'')') xlabel('normalized axial distance z (units of a^2/\lambda)') zlabel('normalized pressure') fix_axis(gca, 1)

problem 2

xp = 0:.025:1.5; % units of a zp = 0:.01:1; % units of a^2/lambda Nxo = length(xp); Nzo = length(zp); pressure = complex(zeros(length(xp), length(zp)), zeros(length(xp), length(zp)));

a = 5; Nxs = 12 * 4 * 2; ix = 1:Nxs; xsource(ix) = a / Nxs * (2 * (ix - Nxs/2) - 1);

Nys = 18 * 4 * 2;

problem 3

xp = 0:.025:1.5; % units of a zp = 0:.01:1; % units of a^2/lambda Nxo = length(xp); Nzo = length(zp); pressure = complex(zeros(length(xp), length(zp)), zeros(length(xp), length(zp)));

a = 2.5; b = 1.5 * a; Nxs = 12 * 4; % 48 ix = 1:Nxs; xsource(ix) = a / Nxs * (2 * (ix - Nxs/2) - 1);

Nys = 18 * 4; iy = 1:Nys; % 72 ysource(iy) = b / Nys * (2 * (iy - Nys/2) - 1);

deltax = xsource(2) - xsource(1); deltay = ysource(2) - ysource(1); wavenum = 2 * pi; % normalized to lambda like the rest

for ixs = 1:Nxs, for iys = 1:Nys, for ixo = 1:Nxo, for izo = 1:Nzo, distance = sqrt((xsource(ixs) - a * xp(ixo))^2 + ysource(iys)^2 + (zp(izo) * a^2)^2);

pressure(ixo, izo) = pressure(ixo, izo) + deltax * deltay * exp(-j * wavenum * distance) / distance; end end end end

mesh(zp, xp, abs(pressure)/max(max(abs(pressure)))) ylabel('normalized lateral distance x (units of half width ''a'')') xlabel('normalized axial distance z (units of a^2/\lambda)') zlabel('normalized pressure') fix_axis(gca, 1)