主要内容

缓冲

缓冲信号向量进入数据帧的矩阵

描述

y= buffer(x,n)划分长度 -Lsignal vectorxinto nonoverlapping data segments (frames) of lengthn

y= buffer(x,n,p)在输出矩阵中的重叠或层次连续帧p样品。

example

y= buffer(x,n,p,选择)指定样品向量以前x(1)在重叠的缓冲区中,或在底层缓冲区中跳过的初始样品数量。

example

[y,z] = buffer(___)划分长度 -Lsignal vectorx长度框架n,并且仅输出完整框架y。The vectorz包含其余样品。该语法可以包括以前语法中输入参数的任何组合。

[y,z,选择] = buffer(___)returns the lastp输出中重叠缓冲区的样本选择

例子

collapse all

创建一个包含100帧的缓冲区,每个帧都有11个样本。

数据=缓冲区(1:1100,11);

Take the frames (columns) in the matrix数据成为数据采集板的顺序输出,对物理信号进行采样:数据(:,1)是第一个A/D输出,包含前11个信号样本,数据(:,2)是第二个输出,包含接下来的11个信号样本,依此类推。

您想拒绝此信号,从获得的框架尺寸11到帧大小为4,重叠为1。缓冲至operate on each successive input frame, using the选择参数以保持从一个缓冲区到另一个缓冲区重叠的一致性。

设置缓冲区参数。指定–5的值y(1)。The carryover vector is empty initially.

n = 4;p = 1;OPT = -5;z = [];

现在反复打电话缓冲,每次通过新的信号框架(列)从数据。溢出样品(返回z) are carried over and prepended to the input in the subsequent call to缓冲

For the first four iterations, show the input frame[z; x]', the input and output values of选择,输出缓冲区y和溢出z。输出矩阵的大小,y,可以因单列从一个迭代到下一个列而变化。这是用重叠或底板缓冲操作的典型特征。

fori = 1:size(data,2)x = data(:,i);[y,z,oppt] = buffer([z; x],n,p,opt);ifi <= 4 disp(''), i, ifrm = [z;x]', opts = [opt oppt], y, z, disp('')end选择= oppt;end

                    
i = 1
ifrm =1×1310 11 1 2 3 4 5 6 7 8 9 10 11
选择=1×2-5 9
y =4×3-5 3 6 1 4 7 2 5 8 3 6 9
z =2×110 11

                    
i = 2
ifrm =1×1222 12 13 14 15 16 17 18 19 20 21 22
选择=1×29 21
y =4×49 12 15 18 10 13 16 19 11 14 17 20 12 15 18 21
Z = 22

                    
i = 3
ifrm =1×1123 24 25 26 27 28 29 30 31 32 33
选择=1×221 33
y =4×421 24 27 30 22 25 28 31 23 26 29 32 24 27 30 33
z = 0x1空双列向量
i = 4
ifrm =1×1343 44 34 35 36 37 38 39 40 41 42 43 44
选择=1×233 42
y =4×333 36 39 34 37 40 35 38 41 36 39 42
z =2×143 44

                    

创建一个包含100帧的缓冲区,每个帧都有11个样本。

数据=缓冲区(1:1100,11);

Take数据(:,1)作为包含前11个信号样本的第一个A/D输出,数据(:,2)as the second output, containing the next 11 signal samples, and so on.

You want to rebuffer this signal from the acquired frame size of 11 to a frame size of 4 with an underlap of 2. To do this, you will repeatedly call缓冲至operate on each successive input frame, using the选择parameter to maintain consistency in the underlap from one buffer to the next.

设置缓冲区参数。指定4个新的框架大小为4,底线为–2。跳过第一个输入元素,x(1), 通过设置选择至1. The carryover vector is empty initially.

n = 4;p = -2;OPT = 1;z = [];

现在反复打电话缓冲,每次通过新的信号框架(列)从数据。溢出样品(返回z) are carried over and prepended to the input in the subsequent call to缓冲

在前三个迭代中,显示输入框架[z';x]', the input and output values of选择,输出缓冲区y和溢出z。输出矩阵的大小,y,可以因单列从一个迭代到下一个列而变化。这是用重叠或底板缓冲操作的典型特征。

fori = 1:size(data,2)x = data(:,i);[y,z,oppt] = buffer([z';x],n,p,opt);ifi <= 3 disp(''), i, ifrm = [z';x]', opts = [opt oppt], y, z, disp('')end选择= oppt;end

                    
i = 1
ifrm =1×111 23 4 5 6 7 8 9 10 11
选择=1×21 2
y =4×22 8 3 9 4 10 5 11
z = 1x0空双行矢量
i = 2
ifrm =1×1420 21 2212 13 14 15 16 17 18 19 20 21 22
选择=1×22 0
y =4×114 15 16 17
z =1×320 21 22

                    
i = 3
ifrm =1×1332 33 23 24 26 26 27 28 29 30 31 32 33
选择=1×20 0
y =4×220 26 21 27 22 28 23 29
z =1×232 33

                    

Input Arguments

collapse all

输入信号,指定为向量。

框架长度,指定为正真实标量。

样品数量,指定为真实的正标量。

  • For0<p<n(重叠),缓冲repeats the finalp在以下框架开始时的每个帧的样本。例如,如果x=1:30n=7,一个重叠p=3看起来像这样。

    The first frame starts withpzeros (the default initial condition), and the number of columns inyisceil(L/(n-p))

  • Forp<0(underlap),缓冲skipsp连续帧之间的样品。例如,如果x=1:30n=7, a buffer with underlap ofp=-3看起来像这样。

    列中的数量yisceil(L/(n-p))

选项,指定为向量或整数。

  • For0<p<n(重叠),选择指定长度 -p向量插入之前x(1)在缓冲区中。该向量可以被视为initial condition当当前的缓冲操作是一系列连续缓冲操作时,需要的是。为了维持从一个缓冲区到另一个缓冲区的所需帧重叠,选择应该包含决赛p序列中先前缓冲液的样品。看连续缓冲以下。

    默认,选择is零(P,1)for an overlapping buffer. Set选择'nodelay'跳过初始条件并立即开始填充缓冲区x(1)。在这种情况下,L一定是长度(P)或更长的时间。例如,如果x=1:30n=7,一个重叠的缓冲区p=3看起来像这样。

  • Forp<0(underlap),选择是该范围内的整数值[0,-P]指定初始输入样本的数量,x(1:opt),在将样品添加到缓冲区之前跳过。因此,缓冲区中的第一个值是X(OPT+1)。默认,选择对于底层缓冲区而言为零。

    当当前的缓冲操作是一系列连续缓冲操作的顺序时,此选项特别有用。为了维护从一个缓冲区到另一个缓冲区的所需框架底线,选择should equal the difference between the total number of points to skip between frames (p) and the number of points that were可用的至be skipped in the previous input to缓冲。如果前面输入少于ppoints that could be skipped after filling the final frame of that buffer, the remaining选择需要从当前缓冲区的第一帧中删除点。看连续缓冲对于在实践中如何工作的示例。

输出参数

collapse all

数据框架,返回为矩阵。每个数据框架占据了一列的y, 其中有nrows andceil(l/n)columns. IfLis not evenly divisible byn,最后一列零填充到长度n

  • Ify是一个重叠的缓冲区,它具有nrows andm列,哪里M =地板(l/(n-p))什么时候长度(opt)= p或者m = ceil((l-p)/(n-p))什么时候opt ='nodelay'

  • Ify是一个底层缓冲区,它具有nrows andm列,哪里m = floor((l-opt)/(n-p)) +(rem((l-opt),(n-p))> = n)

其余样本,作为向量返回。如果输入向量中的样本数(在适当的重叠或底层操作之后)超过了可用的位置数量n-经过-m缓冲区,其余样品中x在矢量中输出z,对于重叠的缓冲区的长度L -M*(N -P)什么时候长度(opt)= p或者l-((M-1)*(n-p)+n)什么时候opt ='nodelay',对于底层缓冲区的长度(L-OPT) - M*(N-P)

  • Ify是重叠的缓冲区或非重叠缓冲区,然后zhas the same orientation (row or column) asx

  • Ify是一个底层缓冲区,然后z作为行向量返回。

如果在带有指定重叠或底层的缓冲区后,输入中没有剩余的样品,zis an empty vector.

最后的p样本,作为向量返回。在底层缓冲区中,选择是跳过框架之间的点总数之间的差异(-p)和点数xthat were available to be skipped after filling the last frame. In a sequence of buffering operations, the选择每个操作的输出应用作选择输入后续缓冲操作。这样可以确保从缓冲区到缓冲区以及从同一缓冲区内的框架之间保持所需的帧重叠或底线。看连续缓冲对于在实践中如何工作的示例。

  • For0<p<n(重叠),选择(as an output) contains the finalp样品in the last frame of the buffer. This vector can be used as theinitial conditionfor 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.

  • Forp<0(underlap),选择(作为输出)是跳过帧之间的点总数之间的差异(p)和点数x填充最后一帧后可以跳过:OPT = M*(N -P) + OPT -L, 在哪里选择右边是输入参数缓冲, 和选择左侧是输出参数。zis the empty vector. Herem是缓冲区中的列数,m = floor((l-opt)/(n-p)) +(rem((l-opt),(n-p))> = n)

    请注意,对于底层缓冲区输出,选择is always zero when outputz包含数据。

    The选择output for an underlapping buffer is especially useful when the current buffering operation is one in a sequence of consecutive buffering operations. The选择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 thanppoints were available to be skipped after filling the final frame of the current buffer, the remaining选择需要从下一个缓冲区的第一帧中删除点。

诊断

显示错误消息时pn或者长度(OPT)长度(P)在重叠的缓冲案例中:

框架重叠P必须小于缓冲尺寸N。必须将初始条件指定为长度-P矢量。

More About

collapse all

连续缓冲

在连续缓冲操作中,向量输入到缓冲函数代表组成离散信号的一系列帧序列。这些信号帧可以起源于基于框架的数据采集过程,也可以源于像FFT这样的基于帧的算法。

例如,您可以从64个样本的帧中获取A/D卡的数据。在最简单的情况下,您可以将数据拒绝为16个样本的帧;缓冲withn=16creates a buffer of four frames from each 64-element input frame. The result is that the signal of frame size 64 has been converted to a signal of frame size 16; no samples were added or removed.

在原始信号框架大小的一般情况下L, is not equally divisible by the new frame size,n,需要捕获最后一帧的溢出并将其回收到以下缓冲区中。您可以通过迭代打电话来做到这一点缓冲on inputx带有两个输出题词语法:

[y,z] = buffer([z; x],n)%x是列向量。[y,z] =缓冲区([z,x],n)%x是行向量。

这只是捕获任何缓冲区溢出z,并将数据预先到下一个呼叫的后续输入中缓冲。同样,输入信号,x,框架尺寸L, has been converted to a signal of frame sizen没有任何插入或删除样品。

Note that continuous buffering cannot be done with the single-output syntaxy =缓冲区(...), because the last frame ofyin this case is zero padded, which adds new samples to the signal.

在存在重叠和底线的情况下连续缓冲选择parameter, which is used as both an input and output to缓冲。此页面上的两个示例演示了选择应使用参数。

扩展功能

看Also

在R2006a之前引入