You are here : matlabSignal Processingbuffer

buffer() - Signal Processing

y = buffer(x,n) partitions
a length-L signal vector x into
nonoverlapping data segments (frames) of length n.
Each data frame occupies one column of matrix output y,
which has n rows and ceil(L/n) columns.
If L is not evenly divisible by n,
the last column is zero-padded to length n.y = buffer(x,n,p) overlaps
or underlaps successive frames in the output matrix by p samples:For 0 < p < n (overlap), buffer repeats
the final p samples of each frame at the beginning
of the following frame. For example, if x = 1:30 and n = 7, an overlap of p = 3 looks like this.
The first frame starts with p zeros (the
default initial condition), and the number of columns in y is ceil(L/(n-p)).For p < 0 (underlap), buffer skips p samples
between consecutive frames. For example, if x = 1:30 and n = 7, a buffer with
underlap of p = -3 looks
like this.
The number of columns in y is ceil(L/(n-p)). y = buffer(x,n,p,opt) specifies
a vector of samples to precede x(1) in an overlapping
buffer, or the number of initial samples to skip in an underlapping
buffer:For 0 < p < n (overlap), opt specifies
a length-p vector to insert before x(1) in
the buffer. This vector can be considered an initial condition,
which is needed when the current buffering operation is one in a sequence
of consecutive buffering operations. To maintain the desired frame
overlap from one buffer to the next, opt should
contain the final p samples of the previous buffer
in the sequence. See Continuous Buffering below.By default, opt is zeros(p,1) for
an overlapping buffer. Set opt to 'nodelay' to
skip the initial condition and begin filling the buffer immediately
with x(1). In this case, L must
be length(p) or longer. For example, if x = 1:30 and n = 7, a buffer with
overlap of p = 3 looks
like this.
For p < 0 (underlap), opt is
an integer value in the range [0,-p] specifying
the number of initial input samples, x(1:opt),
to skip before adding samples to the buffer. The first value in the
buffer is therefore x(opt+1). By default, opt is
zero for an underlapping buffer.This option is especially useful when the current buffering
operation is one in a sequence of consecutive buffering operations.
To maintain the desired frame underlap from one buffer to the next, opt should
equal the difference between the total number of points to skip between
frames (p) and the number of points that were available to
be skipped in the previous input to buffer. If
the previous input had fewer than p points that
could be skipped after filling the final frame of that buffer, the
remaining opt points need to be removed from the
first frame of the current buffer. See Continuous Buffering for an example of how this works in
practice.[y,z] = buffer(...) partitions
the length-L signal vector x into
frames of length n, and outputs only the full frames
in y. If y is an overlapping
buffer, it has n rows and m columns,
where m = floor(L/(n-p)) when length(opt)
= p or m = floor((L-n)/(n-p))+1 when opt
= 'nodelay'.If y is an underlapping buffer, it has n rows
and m columns, where m = floor((L-opt)/(n-p))
+ (rem((L-opt),(n-p)) >= n).If the number of samples in the input vector (after the appropriate
overlapping or underlapping operations) exceeds the number of places
available in the n-by-m buffer,
the remaining samples in x are output in vector z,
which for an overlapping buffer has length L - m*(n-p) when length(opt)
= p or L - ((m-1)*(n-p)+n) when opt
= 'nodelay', and for an underlapping buffer has length (L-opt)
- m*(n-p).Output z shares the same orientation (row
or column) as x. If there are no remaining samples
in the input after the buffer with the specified overlap or underlap
is filled, z is an empty vector.[y,z,opt] = buffer(...) returns
the last p samples of a overlapping buffer in output opt.
In an underlapping buffer, opt is the difference
between the total number of points to skip between frames (-p)
and the number of points in x that were available to
be skipped after filling the last frame:For 0 < p < n (overlap), opt (as
an output) contains the final p samples in the
last frame of the buffer. This vector can be used as the initial
condition for a subsequent buffering operation in a sequence
of consecutive buffering operations. This allows the desired frame
overlap to be maintained from one buffer to the next. See Continuous Buffering below.For p < 0 (underlap), opt (as
an output) is the difference between the total number of points to
skip between frames (-p) and the number of points
in x that were available to
be skipped after filling the last frame: opt = m*(n-p) +
opt - L where opt on the right is the
input argument to buffer, and opt on
the left is the output argument. z is the empty
vector. Here m is the number of columns in the
buffer, which is m = floor((L-opt)/(n-p)) + (rem((L-opt),(n-p))>=n).Note that for an underlapping buffer output opt is
always zero when output z contains
data.The opt output for an underlapping buffer
is especially useful when the current buffering operation is one in
a sequence of consecutive buffering operations. The opt output
from each buffering operation specifies the number of samples that
need to be skipped at the start of the next buffering operation to
maintain the desired frame underlap from one buffer to the next. If
fewer than p points were available to be skipped
after filling the final frame of the current buffer, the remaining opt points
need to be removed from the first frame of the next buffer.In a sequence of buffering operations, the opt output
from each operation should be used as the opt input
to the subsequent buffering operation. This ensures that the desired
frame overlap or underlap is maintained from buffer to buffer, as
well as from frame to frame within the same buffer. See Continuous Buffering below for an example
of how this works in practice.


Syntax

y = buffer(x,n)y = buffer(x,n,p)y = buffer(x,n,p,opt)[y,z] = buffer(...)[y,z,opt] = buffer(...)


Example

Frame overlap P must be less than the buffer size N.
Initial conditions must be specified as a length-P vector.


Output / Return Value


Limitations


Alternatives / See Also


Reference