Main Content

N-Ratio Buffer

Buffer input data into integer-multiple-sized frames

Since R2026a

  • N-Ratio Buffer block

Libraries:
DSP System Toolbox / Signal Management / Buffers

Description

The N-Ratio Buffer block buffers data into blocks of length equal to integer N multiples of the input frame length. The integer ratio N between the output frame length and input frame length is given by the Output-to-input frame length ratio parameter.

Here is an illustration that shows how the block buffers the data. By default, the buffer is initialized with zeros. As new data comes in, the block groups this data into lengths of the specified size. When sufficient data is not available, the block outputs zeros.

Schematic showing input samples being converted into data of frame length 5.

The N-Ratio Buffer block optimizes the memory used in the generated code for P- to NP-frame conversion.

Examples

expand all

Use the N-Ratio Buffer block to buffer multichannel signals of frame length 1 into multichannel signals of frame length N, where N is a positive integer greater than 1.

This figure is a graphical representation of a signal with frame length 1 converted into a signal of frame length N by the N-Ratio Buffer block.

In this example, a two-channel 1-sample-per-frame signal is buffered into a two-channel 4-samples-per-frame signal using an N-Ratio Buffer block.

Open the ex_nratiobuffer_tut model. The Signal From Workspace block has these parameters set:

  • Signal = [1:10;-1:-1:-10]'

  • Sample time = 1

  • Samples per frame = 1

  • Form output after final data value = Setting to zero

Based on these parameters, the Signal from Workspace block outputs a signal with a frame length of 1 and a sample period of 1 second. Because you set the Samples per frame parameter to 1, the Signal From Workspace block outputs one two-channel sample at each sample time.

Save these parameters and close the dialog box by clicking OK.

Double-click the N-Ratio Buffer block and set Output-to-input frame length ratio to 4. The N-Ratio Buffer block outputs a signal with a frame length of 4.

Run the model.

This figure shows the model behavior during simulation.

Ports

Input

expand all

Specify the data input as a scalar, vector, or a matrix of size P-by-Q.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point
Complex Number Support: Yes

Output

expand all

Output of the N-ratio buffer, returned as a scalar, vector, or a matrix of size NP-by-Q, where N is the value you specify in the Output-to-input frame length ratio parameter.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point
Complex Number Support: Yes

Parameters

expand all

To edit block parameters interactively, use the Property Inspector. From the Simulink® Toolstrip, on the Simulation tab, in the Prepare gallery, select Property Inspector.

Specify the ratio of the output frame length to the input frame length, N, as a positive integer.

Block Characteristics

Data Types

Boolean | double | fixed point | integer | single

Direct Feedthrough

no

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

no

Extended Capabilities

expand all

Version History

Introduced in R2026a