Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

rectpuls

Sampled aperiodic rectangle

Syntax

y = rectpuls(t)
y = rectpuls(t,w)

Description

y = rectpuls(t) returns a continuous, aperiodic, unity-height rectangular pulse at the sample times indicated in array t, centered about t = 0 and with a default width of 1. Note that the interval of nonzero amplitude is defined to be open on the right, that is, rectpuls(-0.5) = 1 while rectpuls(0.5) = 0.

y = rectpuls(t,w) generates a rectangle of width w.

rectpuls is typically used in conjunction with the pulse train generating function pulstran.

Examples

collapse all

Generate 200 ms of a rectangular pulse with a sample rate of 10 kHz and a width of 20 ms.

fs = 10e3;
t = -0.1:1/fs:0.1;

w = 20e-3;

x = rectpuls(t,w);

Generate two copies of the same pulse:

  • One displaced 45 ms into the past.

tpast = -45e-3;
xpast = rectpuls(t-tpast,w);
  • One displaced 60 ms into the future and half as wide.

tfutr = 60e-3;
xfutr = rectpuls(t-tfutr,w/2);

Plot the original pulse and the two copies on the same axes.

plot(t,x,t,xpast,t,xfutr)
ylim([-0.2 1.2])

Introduced before R2006a

Was this topic helpful?