% Transmission Line Animation. Animates the lossless transmission line % % Input data includes the characteristic impedance Z0, the load impedance % ZL, the source impedance Zg, the line length L in meters, the phasor % source voltage Vs in rectangular form, the propagation velocity up, and % the frequency of operation f in hertz. % This m-file was written at the University of Wyoming in the Electrical % and Computer Engineering Department and is to be distributed without % cost. clear all set(0,'DefaultAxesFontSize',12); set(0,'DefaultTextFontSize',12); L=5500;%Line length in meters, input data Vg=1;%Source voltage in phasor form (rectangular form), input data up=2e8;%1.897e8;%3e8;%Propagation velocity on the line, input data Z0=300;%Line characteristic impedance (real), input data Zg=300;%Source impedance (rectangular form), input data f=1e5;%Frequency of driving source in Hz., input data %Calculate these from input data clc disp([' The Line Length L = ' num2str(L) ' meters']); disp([' The Source Voltage Amplitude Vg = ' num2str(Vg) ' volts']); disp([' The Source Impedance Zg = ' num2str(Zg) 'ohms']); disp([' The Propagation Velocity up = ' num2str(up) ' m/s']); disp([' The Line Characteristic Impedance = ' num2str(Z0) ' ohms']); disp([' The Frequency of Operation = ' num2str(f) ' Hz']); disp(' ') betaL=2*pi*L*f/up; zoverL=[-1:.01:0]; lambda=up/f; ZL=input(' The load impedandce ZL = '); Zin=Z0*((ZL+j*Z0*tan(betaL))/(Z0+j*ZL*tan(betaL))); gamma=(ZL-Z0)/(ZL+Z0); disp(' ') disp([' The Reflection Coefficient = ',num2str(gamma)]); if abs(gamma)==1 VSWR=Inf; else VSWR=(1+abs(gamma))/(1-abs(gamma)); end Strg2=[' The Voltage Standing Wave Ratio = ',num2str(VSWR)]; Strg1=[' The Reflection Coefficient = ',num2str(gamma)]; disp([' The Input Impedance to the Line = ', num2str(Zin) ' ohms']); disp([' The Wavelength on the Line = ' num2str(lambda) ' meters']); Fact=(Vg*Zin/(Zg+Zin))/(exp(j*betaL)+gamma*exp(-j*betaL)); Vofz=Fact*(exp(-j*betaL*zoverL)+gamma*exp(j*betaL*zoverL)); lim=max(abs(Vofz)); figure(1);clf;%Plot the so-called standing wave pattern axis([-1 0 0 1.2*lim]) hold on box on plot(zoverL,abs(Vofz)); lim=max(abs(Vofz)); xlabel('Dimensionless Distance, z/L') ylabel('Standing Wave Amplitude') text(-.9,.1*lim,Strg1) text(-.9,.2*lim,Strg2) hold off text(-.9,1.1*lim,'Press Enter to Continue') pause mag=abs(Vofz); angl=angle(Vofz); omegat2=linspace(0,4*pi,101); Vin=Vg*Zin/(Zin+Zg); VL=Vin*((1+gamma)/(exp(j*betaL)+gamma*exp(-j*betaL))); Vint=abs(Vin)*cos(omegat2+angle(Vin)*ones(1,101)); VLt=abs(VL)*cos(omegat2+angle(VL)*ones(1,101)); Vgt=abs(Vg)*cos(omegat2+angle(Vg)*ones(1,101)); lim2=max(abs([Vg VL Vin])); figure(2);clf;%Plot vg(t), vin(t) and vL(t) axis([0 4*pi -1.1*lim2 1.1*lim2]) hold on box on plot([0 omegat2(1,101)], [0 0]) hold on plot(omegat2,Vint,'--',omegat2,VLt,'-.',omegat2,Vgt,'.') xlabel('Dimensionless Time, \omega t') ylabel('v_g(t), v_i_n(t), v_L(t), volts') text(5,-.6*abs(Vg),'v_i_n - - - -','FontSize',12) text(5,-.8*abs(Vg),'v_g . . . .','FontSize',12) text(5,-abs(Vg),'v_L . - . - . -','FontSize',12) text(.4*pi,abs(Vg),'Press Enter to Continue') hold off pause % calculate the animation data omegat=linspace(0,8*pi,801); framedata=zeros(801,101); for i=1:801 framedata(i,:)=mag.*cos(omegat(1,i)*ones(1,101)+angl); end figure(3);clf;%Plot v(z) for various times axis([-1.2 .2 -1.2*lim 1.2*lim]) hold on box on xlabel('Dimensionless Distance on the Line, z/L') ylabel('Line Voltage, v(z,t)') thnd1=text(-.9,1.1*lim,'Press Enter to Animate'); text(-1,1.1*lim,' ') set(thnd1,'String',' ') for i=1:20:201%121 plot(zoverL,framedata(i,:),'k'); hold on pause(.4) end text(-.9,-1.1*lim,'\omega\Deltat = \pi/5') text(-.9,1.1*lim,'Press Enter to Animate') pause figure(4);clf;% Animate v(z,t) axis([-1.2 .2 -1.2*lim 1.2*lim]) hold on box on L=plot(zoverL,framedata(1,:),'k','EraseMode','xor'); hold on plot([-1 -1],[-1.2*lim 1.2*lim]) hold on plot([0 0],[-1.2*lim 1.2*lim]) hold on M=plot([-1 0],[framedata(1,1) framedata(1,101)],'o','EraseMode','xor'); xlabel('Dimensionless Distance on the Line, z/L') ylabel('Line Voltage, v(z,t)') thnd1=text(-.9,1.1*lim,'Press Enter to Animate'); pause text(-1,1.1*lim,' ') set(thnd1,'String',' ') for i=1:801 set(L,'Ydata',framedata(i,:)) set(M,'Ydata',[framedata(i,1),framedata(i,101)]) pause(.01) end text(-.9,1.1*lim,'Press Enter to Continue') hold off pause tdata=linspace(0,8*pi,801); [Y,X]=meshgrid(omegat,zoverL); figure(5);clf; %3-d plotof v(z,t) axis([-1 0 0 8*pi -1.1*lim 1.1*lim]) hold on mesh(X,Y,framedata') view(45,30) text( -.8,0,-1.5*lim,'Distance, z/L','Rotation', -18) text(0, 8,-1.5*lim,'Dimensionless Time, \omegat','Rotation',20) zlabel('Line Voltage, v(z,t)') grid on text(-1,30,lim,'Press Enter to Continue', 'Rotation',-18) pause