% Animates the propagation of a pulse on a lossless transmission line % with resistive source and load. The pulse at ther source is % Vg volts high and has a duration of f*L/up sec. where f is a decimal % fraction. The source resistance is Rg and the load resistance is RL. % The source is attached to the line at z=-L and the load at z=0. % 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); clc f=-.5;Vg=-2;Rg=-100;Z0=-100;RL=-100; disp('The temporal duration of the pulse is to be a fraction') disp('of the transit time, L/up, where L is the line length') disp('and up is the propagation velocity') disp('Tpulse = f*L/up where f is a positive decimal fraction') disp('Author suggests 0.1<=f<=0.8') while f<=0 f=input(' f = '); end while Vg<=0 Vg=input(' The height of the pulse at the source in volts Vg = '); end while Rg<0 Rg=input(' The source resistance Rg = '); end while Z0<=0 Z0=input(' The line characteristic impedance Z0 is real and Z0 = '); end while RL<0 RL=input(' The load resistance RL = '); end n1=fix(200*f); V0=Vg*Z0/(Z0+Rg); gammaL=(RL-Z0)/(RL+Z0); disp(' '); disp([' The load reflection coefficient GammaL = ' num2str(gammaL)]); gammag= (Rg-Z0)/(Rg+Z0); disp([' The source reflection coefficient Gammag = ' num2str(gammag)]); a0=V0;a1=gammaL*a0;a2=gammag*a1;a3=gammaL*a2;a4=gammag*a3; %set upper and lower limits for plots if gammaL>=0&gammag>=0 lim1=1.1*(1+gammaL)*V0; lim2=-.5*V0; ztextloc=1.2*lim2; end if gammaL<=0&gammag>=0 lim1=1.2*V0; lim2=-1.2*V0; ztextloc=1.4*lim2; end if gammaL>=0&gammag<=0 lim1=1.2*(1+gammaL)*V0; lim2=-lim1; ztextloc=1.4*lim2; end if gammaL<=0&gammag<=0 lim1=1.2*V0; lim2=-lim1; ztextloc=1.4*lim2; end z=linspace(-1,0,201); vwave=zeros(1,1821); pulse=ones(1,n1+1); vwave(1,401-n1:401)=a2*pulse; vwave(1,801-n1:801)=a0*pulse; vwave(1,1201:1201+n1)=a1*pulse; vwave(1,1601:1601+n1)=a3*pulse; u=vwave(1,801:1001); W=[u]; for i=1:30:571 W=[W;vwave(1,801+i:1001+i)+vwave(1,801-i:1001-i)]; end figure(1);clf; axis([-1.1 .1 lim2 lim1]) hold on box on T1=text(-.95,.9*lim1,'Press Return to Continue'); pause xlabel('Dimensionless Distance Down the Line, z/L') hold on; ylabel('Voltage on the Line, volts') hold on for i=1:9 plot(z,W(i,:)) hold on end text(-.9,.6*lim2,['Pulse Duration = ' num2str(f) '*L/u_p sec.']) text(-.9, .8*lim2,'\Deltat = 3*L/(20u_p)') set(T1,'String','Press Return to Continue'); hold off pause figure(2);clf; axis([-1.1 .1 lim2 lim1]) hold on lim=2.2*V0; plot([0 0],[lim2 lim1]) hold on plot([-1 -1],[lim2 lim1]) hold on text(-.9,.6*lim2,['Pulse Duration = ' num2str(f) '*L/u_p sec.']) hold on; xlabel('Dimensionless Position Down the Line, z/L') hold on; ylabel('Voltage on the Line, volts') hold on; U=[u]; P=plot(z,u,'EraseMode','xor'); box on VL=[u(1,201)]; V1=[u(1,195)]; T=text(-.9,.9*lim1,'Press Enter to Continue'); pause set(T,'String',' '); %pulse is n1 spatial steps wide(n1+1 samples) for i=1:800 u=vwave(1,801+i:1001+i)+vwave(1,801-i:1001-i); set(P,'Ydata',u); VL=[VL u(1,201)]; V1=[V1 u(1,195)]; pause(.01) if fix(i/2)~=i/2 U=[U;u]; end end box on set(T,'String','Press Enter to Continue'); pause %hold off t=linspace(0,4,801); figure(3);clf; axis([0 t(1,801) lim2 lim1]) hold on box on plot(t,VL,'k--',t,V1,'k-') xlabel('Dimensionless Time, u_pt/L'); ylabel('Voltage on the Line, volts,v(z_i,t)'); text(1.7,.95*lim1,'dashes = v(0,t)'); text(1.7,.8*lim1,['line = v(-0.03*L,t)']); text(1.5,.6*lim2,['Pulse Duration = ' num2str(f) '*L/u_p sec.']); text(1.5,.95*lim2,'Press Enter to Continue'); pause %hold off figure(4);clf;%3-D Plot axis([-1 0 0 3 lim2 lim1]) hold on t1=linspace(0,3,51); z1=linspace(-1,0,51); UU=[]; for i=0:50 UU(i+1,:)=U(5*i+1,1:4:201); end [Z,T]=meshgrid(z1,t1); mesh(Z,T,UU,'Edgecolor',[0 0 0]); newmapdata=colormap; newmapdata=ones(size(newmapdata)); colormap=newmapdata; %ztextloc=-.75*(lim1-lim2); text(-.9,0,1.3*ztextloc,'Distance, z/L','Rotation',-15); text(0,1.5,1.5*ztextloc,'Time, u_pt/L','Rotation',43); zlabel('Line Voltage, v(z,t)'); text(-.8,3,lim1, 'Press Return to Continue','Rotation',-15); view(30,50);