# MATLAB Code that computes TL input impedance wouldn't produce the plot I want

#### confuseddesigner

Joined Mar 14, 2017
9
I wrote two functions (Zin_real and Zin_imaginary) to compute the real and imaginary part of transmission line input impedance,
and I use the main program (Part1CaseA) to call the two functions with the parameter "electrical_length" being a matrix 1x1333 matrix.
But the functions return only a single value rather than a 1X1333 matrix. I can't figure out what's going on. Code is pasted below:
Code:
%Part1CaseA:
%Zo: characteristice impedance
zo = 50;
zl = 10;
electrical_length = 0:3*pi/1000:4*pi;
impedance_real = Zin_real (zo, zl, electrical_length);
impedance_imaginary = Zin_imaginary (zo, zl, electrical_length);
figure(1)
plot(electrical_length, impedance_real, electrical_length, impedance_imaginary)
ylabel('impedance magnitude (ohms)')
title('Figure 1. The magnitudes of the real and complex parts of input impedance as functions of the electrical length')

function real_part = Zin_real (Zo, Zl, ElectricalLength)
TanBl = tan(ElectricalLength);
Zin = Zo * ((Zl+(1i)*Zo*TanBl)/(Zo+(1i)*Zl*TanBl));
real_part = real (Zin)

function imaginary_part = Zin_imaginary (Zo, Zl, ElectricalLength)
TanBl = tan(ElectricalLength);
Zin = Zo * ((Zl+(1i)*Zo*TanBl)/(Zo+(1i)*Zl*TanBl));
imaginary_part = imag (Zin)