| Signal Processing Blockset™ | ![]() |
Signal Operations
dspsigops
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 delays the output samples by an integer
number of sample periods D, where
, so that any of the L possible output phases can
be selected.
This block supports triggered subsystems if, for Frame-based mode, you select Maintain input frame rate.
When the input is sample based, the block treats each of the M*N matrix elements as an independent channel, and upsamples each channel over time. The Frame-based mode parameter must be set to Maintain input frame size. The output sample rate is L times higher than the input sample rate (Tso = Tsi/L), and the input and output sizes are identical.
When the input is frame based, the block treats each of the N input columns as a frame containing Mi sequential time samples from an independent channel. The block upsamples each channel independently by inserting L-1 rows of zeros between each row in the input matrix. The Frame-based mode parameter determines how the block adjusts the rate at the output to accommodate the added rows. There are two available options:
Maintain input frame size
The block generates the output at the faster (upsampled) rate by using a proportionally shorter frame period at the output port than at the input port. For upsampling by a factor of L, the output frame period is L times shorter than the input frame period (Tfo = Tfi/L), but the input and output frame sizes are equal.
The model below shows a single-channel input with a frame period of 1 second being upsampled by a factor of 4 to a frame period of 0.25 second. The input and output frame sizes are identical.

Maintain input frame rate
The block generates the output at the faster (upsampled) rate by using 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.
The model below shows a single-channel input of frame size 16 being upsampled by a factor of 4 to a frame size of 64. The input and output frame rates are identical.

The Upsample block has zero-tasking latency for all single-rate operations. The block is single-rate for the particular combinations of sampling mode and parameter settings shown in the table below.
| Sampling Mode | Parameter Settings |
|---|---|
Sample based | Upsample factor parameter, L, is 1. |
Frame based | Upsample factor parameter, L, is 1, or Frame-based mode parameter is Maintain input frame rate. |
The block also has zero latency for all multirate operations in the Simulink single-tasking mode.
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. The Initial condition parameter value is not used.
The Upsample block has tasking latency only for multirate operation in the Simulink multitasking mode:
In sample-based 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 condition value can be an Mi-by-N matrix containing one value for each channel, or a scalar to be applied to all signal channels.
In frame-based 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 condition value can be an Mi-by-N matrix, or a scalar to be repeated across all elements of the Mi-by-N matrix. See the example below for an illustration of this case.
Note For more information on latency and the Simulink tasking modes, see Excess Algorithmic Delay (Tasking Latency) and Models with Multiple Sample Rates in the Real-Time Workshop User's Guide. |
Construct the frame-based model shown below.

Adjust the block parameters as follows:
Configure the Signal From Workspace block to generate a two-channel signal with frame size of 4 and sample period of 0.25. This represents an output frame period of 1 (0.25*4). The first channel should contain the positive ramp signal 1, 2, ..., 100, and the second channel should contain the negative ramp signal -1, -2, ..., -100.
Signal = [(1:100)' (-1:-1:-100)']
Sample time = 0.25
Samples per frame = 4
Configure the Upsample block to upsample the two-channel input by increasing the output frame rate by a factor of 2 relative to the input frame rate. Set a sample offset of 1, and an initial condition matrix of

Upsample factor = 2
Sample offset = 1
Initial condition = [11 -11;12 -12;13 -13;14 -14]
Frame-based mode = Maintain input frame size
Configure the Probe blocks by clearing the Probe width and Probe complex signal check boxes (if desired).
This model is multirate because there are at least two distinct frame rates, as shown by the two Probe blocks. To run this model in the Simulink multitasking mode, open the Configuration Parameters dialog box. In the Select pane, click Solver. From the Type list, select Fixed-step, and from the Solver list, select Discrete (no continuous states). From the Tasking mode for periodic sample times list, select MultiTasking. Also set the Stop time to 30.
Run the model and look at the output, yout. The first few samples of each channel are shown below.
yout =
0 0
11 -11
0 0
12 -12
0 0
13 -13
0 0
14 -14
0 0
1 -1
0 0
2 -2
0 0
3 -3
0 0
4 -4
0 0
5 -5
0 0
Since we ran this frame-based multirate model in multitasking mode, the first row of the initial condition matrix appears as output sample 2 (that is, sample D+1, where D is the Sample offset value). It is followed by the other three initial condition rows, each separated by L-1 inserted rows of zeros, where L is the Upsample factor value of 2. The first row of the first input matrix appears in the output as sample 10 (that is, sample MiL+D+1, where Mi is the input frame size).

The integer factor, L, by which to increase the input sample rate.
The sample offset, D, which must be an integer in the range [0,L-1].
The value with which the block is initialized for cases of nonzero latency, a scalar or matrix. This value (first row in frame-based mode) appears in the output as sample D+1.
For frame-based operation, the method by which to implement the upsampling: Maintain input frame size (that is, increase the frame rate), or Maintain input frame rate (that is, increase the frame size). The Framing parameter must be set to Maintain input frame size for sample-base inputs.
| Port | Supported Data Types |
|---|---|
Input |
|
Output |
|
| Downsample | Signal Processing Blockset |
| FIR Interpolation | Signal Processing Blockset |
| FIR Rate Conversion | Signal Processing Blockset |
| Repeat | Signal Processing Blockset |
![]() | Unwrap | Variable Fractional Delay | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |