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


Joined Nov 25, 2011
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 :)