Skip to content

Instantly share code, notes, and snippets.

@OlliV
Created February 27, 2012 23:54
Show Gist options
  • Save OlliV/1927988 to your computer and use it in GitHub Desktop.
Save OlliV/1927988 to your computer and use it in GitHub Desktop.
Attenuation Coefficient Calculator on Matlab
% -------------------------------------------------------------------------
% | Attenuation Coefficient Calculator |
% | ================================== |
% | Olli Vanhoja |
% | 2010-08-26 |
% -------------------------------------------------------------------------
clear all
close all
close all hidden
clc
% Parameters
f = 1*10^9; % Frequency [Hz]
E_0 = 1;
x = 1; % Distance [m]
e_r = 78; % e_r' (Real)
e_ri = 0.1; % e_r'' (Imaginary)
mu_r = 1;
sigma = 4; % Conductivity (sigma) [S/m]
% Constants
c_0 = 299792458;
mu_0 = 4*pi*10^-7;
e_0 = 1/(mu_0*c_0^2);
j = sqrt(-1); % Imaginary unit
eps = e_0*e_r;
mu = mu_0*mu_r;
omega = 2*pi*f;
gamma = j*omega*sqrt(mu*eps)*sqrt(1-j*(sigma)/(omega*eps));
E = exp(-gamma*x)/E_0;
G = 20*log10(exp(-real(gamma)));
fprintf('gamma = %f\nRe E = %e\nAttenuation = %f dB/m\n', real(gamma), real(E), G);
@xinliulab
Copy link

Thanks!

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