Thursday, August 18, 2016

Matlab code to calculate the voltage on the transmission line


% This matlab code is setup for calculating the voltage on the 
% transmission line. The code will then plot the results. 
% frequency is 13.5Mhz


% Clear the screen
clc;
clear all;
% close all windows
close all;


%% input values 
RL = 20;        % resistive part of load
CL = 3.3e-9;    % capacitive part of load
len = 80;       % transmission line length
freq = 13.5e+6;  % frequency
omega = 2*pi*freq;
Z0 = 50;        % characteristic impedance of line
v = 2e+8;       % velocity in RG 58 cable
ZS = 50;        % source impedance

%% set up the node measurements with arbitrary values

z_node = [0:4:len];      % equivalent position of nodes on transmission line

V_node = [0 1 2 3.1 4 5 6 7 8.2 9 10 11.4 12 13 14 15 16 17];
V_node = [V_node 18.1 19 20.5];

%%set up phase measurements with arbitrary values
phase_node = [0 1 2 3.1 4 5 6 7 8.2 9 10 11.4 12 13 14 15 16 17];
phase_node = [phase_node  18.1 19 20.5];


%%calculating the transmission line voltage 

z = [0:1:len];                  % z position on line
ZL = RL - j./omega./CL;         % load impedance
V_line = ZL .* z .* exp(-j.*omega.*z./v) ./len;


%% Find the magnitude and angle of the voltage phasor
V_line_mag = abs(V_line);
V_line_deg = 180*angle(V_line)./pi;


%% Plot results
figure(1);
subplot(2,1,1), plot(z,V_line_mag, z_node, V_node, 'o');
title('Unmodified line vs. V magnitude');
ylabel('V magnitude');
legend('trans. line analysis','circuit analysis', 0);
subplot(2,1,2), plot(z,V_line_deg, z_node, phase_node, 'o');
title('Unmodified line vs. phase');
ylabel('phase(degrees)');
xlabel('z position on line (meters)');
legend('trans. line analysis','circuit analysis', 0);


No comments:

Post a Comment