can anyone tell me how to plot the rectangular wave in matlab

Discussion in 'Programmer's Corner' started by ujwala, Jan 29, 2012.

  1. ujwala

    Thread Starter New Member

    Jan 29, 2012
    1
    0
    can anyone tell me tht how to plot the rectangular wave in matlab
     
  2. holnis

    Member

    Nov 25, 2011
    50
    4
    Here is the Algorithm to do it :

    1. Set the frequency,f , the amplitude, A, and the number of cycles desired, N as inputs to your function.

    2. Compute the time period T=1/f

    3. Compute the ON time P=(D/100)T

    4. Assign a desired range to the time, t such that t=[t1,t2] where t1=0:inc:p, t2=P:inc:T and inc <= 1/2f

    5. Generate the samples of rectangular wave for desired number of cycles

    6. Plot the rectangular wave.

    Hope this Helps :)
     
Loading...