How to draw Reflection coefficient in MATLAB

2.3k Views Asked by At

I am trying to plot Reflection coefficient by using the formula indicated on the attached image and use the Matlab code below:

Note: I use MATLAB R2015a

E1=1;
E2=2.32*E1; 

for tetai=1:90      
    numerator=cos(tetai)-(sqrt(E2/E1).*sqrt(1-(E1/E2).*sin(tetai)^2));
    denominator=cos(tetai)+(sqrt(E2/E1).*sqrt(1-(E1/E2).*sin(tetai)^2));
    eta=numerator/denominator;
    plot(tetai,eta,'r');
    hold on;
end     

title('Plots')
xlabel('\Theta')
ylabel('\Gamma')

enter image description here

After repeating E2 values with 2.56, 4, 9, 16, 25, and 81 I should obtain the following result (At first step I just wanted to obtain a single value with E2=2.32):

enter image description here

But unfortunately, there is no graphics on the plot result screen. So, what is the mistake?

1

There are 1 best solutions below

1
On BEST ANSWER

Your MATLAB code should use vectors (and convert degrees to radians), and the given LaTeX formula is backwards (the two terms being subtracted in the numerator are the wrong way around). I ran the following code:

e1 = 1;
theta_deg = 0 : 0.01 : 90;
theta_rad = theta_deg * pi/180;
e2_vals = [2.56, 4, 9, 16, 25, 81];
gammas = nan(length(e2_vals), length(theta_deg));
for i = 1:length(e2_vals)
    e2 = e2_vals(i);
    t1 = sqrt(e2/e1) * sqrt(1 - (e1/e2) * sin(theta_rad).^2);
    t2 = cos(theta_rad);
    gammas(i, :) = (t1 - t2) ./ (t1 + t2);
end

plot(theta_deg, gammas)
grid on
xlabel('Incident Angle \theta_i (degrees)');
ylabel('Reflection coefficient [\Gamma^b_\perp]')
axis([0, 90, 0, 1])
legend(strcat({'\epsilon_2 = '}, num2str(e2_vals'))', 'Location', 'SE')

This yielded the following plot, which seems to agree with the expected graph: enter image description here