Accelerating the pace of engineering and science

# Upsample

Resample input at higher rate by inserting zeros

## Library

Signal Operations

dspsigops

## Description

The Upsample block resamples each channel of the Mi-by-N input at a rate L times higher than the input sample rate by inserting L-1 zeros between consecutive samples. You specify the integer L in the Upsample factor parameter. The Sample offset parameter, D, allows you to delay the output samples by an integer number of sample periods. Doing so enables you to select any of the L possible output phases. The value you specify for the Sample offset parameter must be in the range $0\le D<\left(L-1\right)$.

You can use this block inside of triggered subsystems when you set the Rate options parameter to Enforce single-rate processing.

### Frame-Based Processing

When you set the Input processing parameter to Columns as channels (frame based), the block upsamples each column of the input over time. In this mode, the block can perform either single-rate or multirate processing. You can use the Rate options parameter to specify how the block upsamples the input:

• When you set the Rate options parameter to Enforce single-rate processing, the input and output of the block have the same sample rate. In this mode, the block outputs a signal with a proportionally larger frame size than the input. For upsampling by a factor of L, the output frame size is L times larger than the input frame size (Mo = Mi*L), but the input and output frame rates are equal.

For an example of single-rate upsampling, see Example: Single-Rate Processing.

• When you set the Rate options parameter to Allow multirate processing, the block treats an Mi-by-N matrix input as N independent channels. The block upsamples each column of the input over time by keeping the frame size constant (Mi=Mo), and making the output frame period (Tfo) L times shorter than the input frame period (Tfo = Tfi/L).

See Example: Multirate, Frame-Based Processing for an example that uses the Upsample block in this mode.

### Sample-Based Processing

When you set the Input processing parameter to Elements as channels (sample based), the block treats an M-by-N matrix input as M*N independent channels, and upsamples each channel over time. In this mode, the block always performs multirate processing. The output sample rate is L times higher than the input sample rate (Tso = Tsi/L), and the input and output sizes are identical.

### Zero Latency

The Upsample block has zero-tasking latency for all single-rate operations. The block is in a single-rate mode if you set the Upsample factor parameter to 1 or if you set the Input processing parameter to Columns as channels (frame based) and the Rate options parameter to Enforce single-rate processing.

Zero-tasking latency means that the block propagates the first input (received at t=0) immediately following the D consecutive zeros specified by the Sample offset parameter. This output (D+1) is followed in turn by the L-1 inserted zeros and the next input sample.

### Nonzero Latency

• In multirate, sample-based processing mode, the initial condition for each channel appears as output sample D+1, and is followed by L-1 inserted zeros. The channel's first input appears as output sample D+L+1. The Initial conditions parameter can be an Mi-by-N matrix containing one value for each channel, or a scalar to be applied to all signal channels.

• In multirate, frame-based processing mode, the first row of the initial condition matrix appears as output sample D+1, and is followed by L-1 inserted rows of zeros, the second row of the initial condition matrix, and so on. The first row of the first input matrix appears in the output as sample MiL+D+1. The Initial conditions parameter can be an Mi-by-N matrix, or a scalar to be repeated across all elements of the input matrix.

## Examples

Example: Single-Rate Processing

In the ex_upsample_ref2ex_upsample_ref2 model, the Upsample block resamples a single-channel input with a frame size of 16. The block upsamples the input by a factor of 4. Thus, the output of the block has a frame size of 64. Because the block is in single-rate processing mode, the input and output frame rates are identical.

Example: Multirate, Frame-Based Processing

In the ex_upsample_ref1ex_upsample_ref1 model, the Upsample block resamples a single-channel input with a frame period of 1 second. The block upsamples the input by a factor of 4. Thus, the output of the block has a frame period of 0.25 seconds. Because the block is in multirate processing mode, the input and output frame sizes are identical.

## Dialog Box

Upsample factor

The integer factor, L, by which to increase the input sample rate.

Sample offset

The sample offset, D, which must be an integer in the range [0,L-1].

Input processing

Specify how the block should process the input. You can set this parameter to one of the following options:

• Columns as channels (frame based) — When you select this option, the block treats each column of the input as a separate channel. In this mode, the block can perform single-rate or multirate processing.

• Elements as channels (sample based) — When you select this option, the block treats each element of the input as a separate channel. In this mode, the block always performs multirate processing.

 Note:   The option Inherit from input (this choice will be removed - see release notes) will be removed in a future release. See Frame-Based Processing in the DSP System Toolbox™ Release Notes for more information.
Rate options

Specify the method by which the block upsamples the input. You can select one of the following options:

• Enforce single-rate processing — When you select this option, the block maintains the input sample rate by increasing the output frame size by a factor of L. To select this option, you must set the Input processing parameter to Columns as channels (frame based).

• Allow multirate processing — When you select this option, the block resamples the signal such that the output sample rate is L times faster than the input sample rate.

Initial conditions

The value with which the block is initialized for cases of nonzero latency, a scalar or matrix. This value appears in the output as sample D+1. This parameter appears only when you configure the block to perform multirate processing.

## HDL Code Generation

This block supports HDL code generation using HDL Coder™. HDL Coder provides additional configuration options that affect HDL implementation and synthesized logic. For more information on implementations, properties, and restrictions for HDL code generation, see Upsample.

## Supported Data Types

PortSupported Data Types

Input

• Double-precision floating point

• Single-precision floating point

• Fixed point (signed and unsigned)

• Boolean

• 8-, 16-, and 32-bit signed integers

• 8-, 16-, and 32-bit unsigned integers

Output

• Double-precision floating point

• Single-precision floating point

• Fixed point (signed and unsigned)

• Boolean

• 8-, 16-, and 32-bit signed integers

• 8-, 16-, and 32-bit unsigned integers