Skip to content

Instantly share code, notes, and snippets.

@sparksbat
Created November 13, 2017 10:06
Show Gist options
  • Select an option

  • Save sparksbat/ba3105a03b13a3ea49168cf60832b6ba to your computer and use it in GitHub Desktop.

Select an option

Save sparksbat/ba3105a03b13a3ea49168cf60832b6ba to your computer and use it in GitHub Desktop.
ECE 306L Pre-Lab 7
clear variables
syms omega
thetas = [
pi/6;
pi/4;
pi/2;
2*pi/3;
5*pi/6
];
Zin = exp(1j*omega);
for iter = 1:length(thetas)
BZ = 1/(1 - 2*cos(thetas(iter))*(Zin^(-1)) + (Zin^(-2)));
dBZ = diff(BZ);
Zval = solve(dBZ == 0, omega);
Zcalc = exp(1j*Zval);
BZOut(iter) = double(1/(1 - 2*cos(thetas(iter))*(Zcalc^(-1)) + (Zcalc^(-2))));
end
clear variables
syms omega
vals = [
pi/6 0.95;
pi/6 0.70;
pi/3 0.95;
pi/3 0.70;
5*pi/6 0.95;
5*pi/6 0.70
];
for iterout = 1:6
r = vals(iterout, 2);
theta = vals(iterout,1);
Z = exp(1j*omega);
BZ = (1 - 2*r*cos(theta)*Z^(-1) + r^2 * Z^(-2))/(1-r);
dBZ = diff(BZ);
Zval = solve(dBZ == 0, omega);
Zcalc = exp(1j*Zval);
BZOut(iterout) = double((1 - 2*r*cos(theta)*Zcalc^(-1) + r^2 * Zcalc^(-2))/(1-r));
end
@sparksbat
Copy link
Author

The value held in BZOut will be an indexed array such that BZOut(i) is the value of b0 for the value theta(i) or vals(i) where vals(i,1) is theta and vals(i, 2) is r.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment