How to plot input reflection coefficient in dB scale using Matlab - Electrical Engineering Stack Exchange most recent 30 from electronics.stackexchange.com 2019-06-26T08:08:12Z https://electronics.stackexchange.com/feeds/question/403311 http://www.creativecommons.org/licenses/by-sa/3.0/rdf https://electronics.stackexchange.com/q/403311 0 How to plot input reflection coefficient in dB scale using Matlab Donald Krambeck https://electronics.stackexchange.com/users/165397 2018-10-26T03:44:01Z 2018-10-26T07:05:09Z <p>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. </p> <pre class="lang-matlab prettyprint-override"><code>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 </code></pre> https://electronics.stackexchange.com/questions/403311/-/403331#403331 1 Answer by TheAndyEngineer for How to plot input reflection coefficient in dB scale using Matlab TheAndyEngineer https://electronics.stackexchange.com/users/108803 2018-10-26T06:57:12Z 2018-10-26T06:57:12Z <p>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.</p> <p>some suggested reading: <a href="https://www.maths.unsw.edu.au/sites/default/files/MatlabSelfPaced/lesson10/MatlabLesson10_LogScale.html" rel="nofollow noreferrer">MATLAB Log scaling</a> <a href="https://www.mathworks.com/help/matlab/ref/semilogx.html" rel="nofollow noreferrer">MATLAB Semilog</a></p>