rectpuls - Sampled aperiodic rectangle - MATLAB (original) (raw)
Main Content
Sampled aperiodic rectangle
Syntax
Description
[y](#mw%5Fbf348f0b-663a-4397-ac92-d0896113fdcb) = rectpuls([t](#mw%5Fb66668a4-9cc9-4dcf-a4be-8ae23c5fa07a))
returns a continuous, aperiodic, unit-height rectangular pulse at the sample times indicated in arrayt
, centered about t
=0
.
[y](#mw%5Fbf348f0b-663a-4397-ac92-d0896113fdcb) = rectpuls([t](#mw%5Fb66668a4-9cc9-4dcf-a4be-8ae23c5fa07a),[w](#mw%5Fcd7164b2-7e2d-43d5-833e-5e6c1b1bca87))
generates a rectangle of width w
.
Examples
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])
Input Arguments
Sample times of unit rectangular pulse, specified as a vector.
Data Types: single
| double
Rectangle width, specified as a positive number.
Output Arguments
Rectangular pulse of unit amplitude, returned as a vector.
Note
The interval of nonzero amplitude is defined to be open on the right, that is,rectpuls(-0.5)
= 1
whilerectpuls(0.5)
= 0
.
Tips
rectpuls
can be used in conjunction with the pulse train generating function pulstran.
Extended Capabilities
Version History
Introduced before R2006a