% Animates the propagation of a step source on a lossless transmission line % with a resistive source and load. The step at the source is 2 % volts high.The source has internal resistance Rg and is attached to the % line at z=-L. The load resistance is RL and the load is attached to the % line 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 Vg=10; Z0=50; Rg=25; RL=75; disp([' The Source Voltage Vg = ' num2str(Vg)]); disp([' The Source Resistance Rg = ' num2str(Rg)]); disp([' The Characteristic Impedance Z0 = ' num2str(Z0)]); RL=input(' The Load Resistance RL = '); V0=Vg*Z0/(Z0+Rg); gammaL=(RL-Z0)/(RL+Z0); gammag=(Rg-Z0)/(Rg+Z0); a0=V0;a1=gammaL*a0;a2=gammag*a1;a3=gammaL*a2; if gammaL>=0&gammag>=0; lim1=1.2*(a0+a1+a2+a3); lim2=-.2*V0; end if gammaL<0&gammag<0; lim1=1.2*V0; lim2=-.2*V0; end if gammaL>0&gammag<0; lim1=1.2*(1+gammaL)*V0; lim2=.2*gammag*gammaL*V0; end if gammaL<0&gammag>0; lim1=1.2*(a0); lim2=-.2*a0; end if gammaL==0; lim1=1.2*(a0); lim2=-.2*a0; end z=linspace(-1, 0,201); w=zeros(1,800); w(1,301:501)=ones(1,201); w0=a0*w; w1=a1*w; w2=a2*w; w3=a3*w; u=w0(1,501:701); figure(1):clf; lim=2.2*V0; axis([-1.1 .1 lim2 lim1]); plot([0 0],[lim2 lim1]); hold on; plot([-1 -1],[lim2 lim1]); hold on; plot([-1.1 .1],[0 0]); hold on; xlabel('Dimensionless Distance Down the Line, z/L') hold on; ylabel('Voltage on the Line, volts') hold on; U=[u]; P=plot(z,u,'EraseMode','xor'); VL=[u(1,201)]; V1=[u(1,101)]; T=text(-.9,.9*lim1,'Press Enter to Continue'); pause set(T,'String',' '); %Dc sourcce Vg applied to line at t=0 for i=1:800 if i>0&i<=199 u=w0(1,501-i:701-i); set(P,'Ydata',u); VL=[VL u(1,201)]; V1=[V1 u(1,51)]; pause(.01) if fix(i/2)~=i/2 U=[U;u]; end end if i>199&i<=399 u=w0(1,301:501)+w1(1,-99+i:101+i); set(P,'Ydata',u); VL=[VL u(1,201)]; V1=[V1 u(1,51)]; pause(.01) if fix(i/2)~=i/2 U=[U;u]; end end if i>399&i<=599 u=w0(1,301:501)+w1(1,301:501)+w2(1,901-i:1101-i); set(P,'Ydata',u); VL=[VL u(1,201)]; V1=[V1 u(1,51)]; pause(.01) if fix(i/2)~=i/2 U=[U;u]; end end if i>599&i<=799 u=w0(1,301:501)+w1(1,301:501)+w2(1,301:501)+w3(1,-499+i:-299+i); set(P,'Ydata',u); VL=[VL u(1,201)]; V1=[V1 u(1,51)]; pause(.01) if fix(i/2)~=i/2 U=[U;u]; end end end box on set(T,'String','Press Enter to Continue'); pause t=linspace(0,4,800); figure(2);clf axis([0 t(1,800) lim2 1.1*lim1]) hold on plot(t,VL,'k--',t,V1,'k-') xlabel('Dimensionless Time, u_pt/L') ylabel('Voltage on the Line, volts') text(2.4,.95*lim1,'- - - denotes v(0,t)') text(2.4,.9*lim1,'___ denotes v(-0.75L,t)') text(.5,lim1,'Press Enter to Continue') box on pause figure(3);clf axis([-1 0 0 3 0 1.5*lim1]) t1=linspace(0,3,81); z1=linspace(-1,0,51); UU=[]; for i=0:80 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; xlabel('Distance, z/L','Rotation',18); ylabel('Time, u_pt/L','Rotation',-45); text(-.8,3,lim1,'Press Enter to Continue','Rotation',18) zlabel('Line Voltage, v(z,t)'); view(330,60)