0
\$\begingroup\$

So I have a problem that asks to plot the input reflection coefficient of a transformer in dB scale between 0.5 GHz and 4 GHz using Matlab. Here is the code I have thus far, it is plotting in Reflection Coefficient (y-axis) vs Frequency (x-axis). I'm not sure how to convert it to the dB scale.

f0 = 1e9;             %% Defining operational frequency
c  = 3e8;             %% Defining speed of light constant
f = [0:0.01:4]*1e9;   %% Defining frequency scale
lambda = c./f;        %% Defining wavelength equation
lambda_0 = c/f0;      %% Defining wavelength equation 
ZL = 120;             %% Defining input impedance 
Z0 = 60;              %% Defining characteristic impedance 
Z0p = sqrt(ZL*Z0);    %% Defining transformer impedance equation
beta = 2*pi./lambda;  %% Defining phase constant equation 
ell = lambda_0/4;     %% Defining quarter wavelength euqation 

t = tan(beta.*ell);   %% Defining time equation

Zin = Z0p * (ZL+j*Z0p.*t)./(Z0p+j*ZL.*t); %% Defining input impedance equation
gamma = (Zin-Z0)./(Zin+Z0);               %% Defining reflection loss equation
agamma = abs(gamma);                      %% Defining abs value of rl

plot(f/1e9,agamma,'b','linewidth',2);     %% Defining plot 
xlabel('frequency (GHz)');                %% Defining x-axis label
ylabel('|\Gamma|');                       %% Defining y-axis label
grid on;                                  %% Grid on
\$\endgroup\$
2
  • 2
    \$\begingroup\$ are you simply asking how to get dB from linear ratio? dB = 20*log10(linear ratio)! \$\endgroup\$ Commented Oct 26, 2018 at 4:36
  • 1
    \$\begingroup\$ 20*log10() for a ratio of fields/voltages/currents. 10*log10() for a ratio of powers. \$\endgroup\$ Commented Oct 26, 2018 at 5:51

1 Answer 1

1
\$\begingroup\$

To do it numerically as others have commented use 10Log10(x). If you wish to plot with logarithmic scaling matlab has options such as log-log (logarithmic on both axis) or semilog (logarithmic on one axis). I think semilog is what your after as I think it would make sense to have frequency in logarithmic scaling and reflection coefficient linear.

some suggested reading: MATLAB Log scaling MATLAB Semilog

\$\endgroup\$