Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Plotting the step function of a summation
Date: Thu, 8 Apr 2010 17:40:21 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 53
Message-ID: <hpl4e5$jej$1@fred.mathworks.com>
References: <hpkuva$ecl$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1270748421 19923 172.30.248.38 (8 Apr 2010 17:40:21 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 8 Apr 2010 17:40:21 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:624743

"Kevin " <kuberakt@notes.udayton.edu> wrote in message <hpkuva$ecl$1@fred.mathworks.com>...
> I am trying to write code for a transmission line problem to plot the net voltage as a function of time.  I have analyzed a pattern for the net voltage at the load as shown below.  The goal is to write summation code in Matlab and superimpose the voltages on a graph.  The variables used are as follows:
> 
> V=amplitude of the voltage
> t=time the pulse travels
> tf=time the pulse reaches the end of the line
> gammaL=propagation constant from the load
> gammaG=propagation constant from the generator
> 
> V= 0, 0<t<tf
>   = v0+v0*gammaL, tf<t<3*tf
>   = v0+v0*gammaL+v0*gammaL*gammaG+v0*gammaL^2*gammaG, 3*tf<t<5*tf
>   =  v0+v0*gammaL+v0*gammaL*gammaG+v0*gammaL^2*gammaG+ v0*gammaL^2*gammaG ^2 + v0*gammaL^3*gammaG ^2, 5*tf<t<7*tf        
> 
> I have written some general pseudocode for the summation, but have not figured out how to perfect it and plot it as a step function.  The pseudocode is as follows:
> 
> % the length of the pulse is 10ms
> 
> tf=2/3e-6;
> gammaL=-1;
> gammaG=1/3;
> Rs=100;
> R0=50;
> v0=1;
> vinitial=0;
> n=15;
> 
> temp1=1;
> temp2=1;
> 
> volt(1)=0;
> volt(2)=v0+v0*gammaL;
> for k=3:n
>     volt(k)=volt(2)+v0*gammaL^temp1+v0*gammaG^temp2;
>     
>     if temp1=temp2
>         temp1=temp1+1;
>     else
>         temp2=temp2+1;
>     end
> end
> 
> %If anyone could help with developing code for the summation and plotting it, I would be very greatful.  I appreciate your help with this for I am not too familiar with Matlab programming.
---------------------
  To generate n elements of 'volt' do this:

 a = v0+v0*gammaL;
 b = gammaL*gammaG;
 volt = a*(1-b.^(0:(n-1)))/(1-b);

This assumes that b is not equal to 1.

Roger Stafford