Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Plotting the step function of a summation

Subject: Plotting the step function of a summation

From: Kevin

Date: 8 Apr, 2010 16:07:06

Message: 1 of 4

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.

Subject: Plotting the step function of a summation

From: Roger Stafford

Date: 8 Apr, 2010 17:40:21

Message: 2 of 4

"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

Subject: Plotting the step function of a summation

From: Kevin

Date: 12 Apr, 2010 17:54:04

Message: 3 of 4

"Roger Stafford"
<ellieandrogerxyzzy@mindspring.com.invalid> wrote in message
> ---------------------
> 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
---------------------------------
That ended up working. I ended up plotting it by using the stairs function and scaling the x-axis. Thanks for the help.

Subject: Plotting the step function of a summation

From: Roger Stafford

Date: 12 Apr, 2010 18:58:04

Message: 4 of 4

"Kevin " <kuberakt@notes.udayton.edu> wrote in message <hpvmns$89k$1@fred.mathworks.com>...
> That ended up working. I ended up plotting it by using the stairs function and scaling the x-axis. Thanks for the help.
----------
  Did you recognize that as the sum of a geometric progression? This identity is frequently encountered in algebra problems:

 1 + b + b^2 + b^3 + ... + b^(N-1) = (1 - b^N)/(1-b)

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us