Electrical Engineer

Wednesday, April 6, 2011

Generate periodic signals (square waves and triangular waves), exponential signals, sinusoidal signals, exponentially damped signals with MATLAB. To visualize the discrete time signal use stem command.

Periodic signal:

A periodic signal x (t) is a function of time that satisfies the condition –
                         x (t) =x (t + T) .............(1)    for all  t,
                                             Where T is a constant. Clearly, if this condition is satisfied for T = T0 ,say, then it is also satisfied for T = 2T0, 3T0, 4T0,...... The smallest value of T that satisfies the eq-1 is called the fundamental period of x (t). Accordingly, the fundamental period T defines the duration of one complete cycle of x (t). The reciprocal of the fundamental period T is called the fundamental frequency of  the periodic  signal x (t); it describe  how  frequently the periodic signal x (t) repeats itsself. we thus formally write-
                   f = 1/T
The frequency f is measured in hertz or cycle per second. The angular frequency, measured in radians per second, is defined by-       
                        
                ω = 2πf = 2π/T 

Example of periodic signal:
                                           
                                   Continuous time Square wave
                                                                     
MAT LA Bcommand:

                                  >>A=2;
                                       >>w = 10*pi;
                                       >>rho = 0.5;
                                       >>t = 0: .001: 1;
                                       >>sq=A*square (w * t , rho );
                                       >>plot (t , sq )
 Description:
                        Here
 A= Amplitude of the signal 
w = Fundamental frequency (measured in radians/second)
                                    rho = Duty cycle
                                    t = 0 : .001 : 1
                                   Time interval = 0 to 1 second
                                  Sampling interval = .001 second
                           plot (t , sq ) is for to plot a continuous time signal

Discrete time square wave

 MAT LAB command:
                                     
  >>A =1;
                                       >>0mega = pi/4;
                                       >> n= -10:10;
                                       >> x = A* square (omega * n);
                                        >> stem (n , x )       


Triangular wave

MAT LA Bcommand:
                                      >>A = 1;
                                                >>w0 =10*pi;
                                                >>w =0.5;
                                                >>t =0 : .001 : 1;
                                                >>tri =A*sawtooth (w0*t ,w);
                                                >>plot (t ,tri )


Discrete time triangular wave


MAT LA Bcommand:

                                     >>A =1;
                                            >>0mega = pi/18;
                                            >> n= -20:20;
                                            >> x = A* sawtooth (omega * n);
                                            >> stem (n , x )   


Exponential signal:

MAT LAB commands for decay exponential signal( x(t) = 5 e-at ):

                                           >>B = 5;
                                           >>a = 6; 
                                           >>t = 0 : .001 : 1;
                                           >>x = B*exp (-a*t );
                                           >>plot (t ,x )

MAT LA Bcommand  for discrete time decay exponential signal:
                                     
>>B = 1;
                                                >>r = 0.85;
                                                >>n = -10 :10;
                                                >>x = B*r. ^ n;
                                                >>stem (n , x )


                         
 Note that , in this example , the base  r is a scalar but the exponent is a vector. Hence the use of the symbol  .^  to denote element by element power. 

MAT LABcommand for growing exponential signal (x(t) = 5eat):
                                     
>>B = 1;
                                                >>a = 5;
                                                >>t =0 : .001 : 1;
                                                >>x = B*exp( a*t );
                                                >>plot( t ,x )

Here B and a are real parameters. The parameter B is the amplitude of the exponential signal measured at the time t = 0.


MAT LABcommand for discrete time growing exponential signal:
                                     
>>B = 1;
                                                >>r = 0.85;
                                                >>n = -10 :10;
                                                >>x = B*r. ^ -n;
                                                >>stem (n , x )






                                     






No comments:

Post a Comment