Main Content

Uniform Random Number

Generate uniformly distributed random numbers

  • Uniform Random Number block

Libraries:
Simulink / Sources

Description

The Uniform Random Number block generates uniformly distributed random numbers over an interval that you specify. To generate normally distributed random numbers, use the Random Number block. Both blocks use the Normal (Gaussian) random number generator ('v4': legacy MATLAB® 4.0 generator of the rng function).

You can generate a repeatable sequence using any Uniform Random Number block with the same nonnegative seed and parameters. The seed resets to the specified value each time a simulation starts.

Avoid integrating a random signal, because solvers must integrate relatively smooth signals. Instead, use the Band-Limited White Noise block.

The numeric parameters of this block must have the same dimensions after scalar expansion. If you select the Interpret vector parameters as 1-D check box and the numeric parameters are row or column vectors after scalar expansion, the block outputs a 1-D signal. If you clear the Interpret vector parameters as 1-D check box, the block outputs a signal of the same dimensionality as the parameters.

Examples

Ports

Output

expand all

Output signal of generated uniformly distributed random numbers over the interval you specify.

Data Types: double

Parameters

expand all

Specify the minimum of the interval.

Programmatic Use

Block Parameter: Minimum
Type: character vector
Values: scalar
Default: '-1'

Specify the maximum of the interval.

Programmatic Use

Block Parameter: Maximum
Type: character vector
Values: scalar
Default: '1'

Specify the starting seed for the random number generator.

The seed must be 0 or a positive integer. Output is repeatable for a given seed.

Programmatic Use

Block Parameter: Seed
Type: character vector
Values: scalar
Default: '0'

Specify the time interval between samples. See Specify Sample Time for more information.

Programmatic Use

Block Parameter: SampleTime
Type: character vector
Values: scalar
Default: '0.1'

Select this check box to output a vector of length N if the Constant value parameter evaluates to an N-element row or column vector.

  • When you select this check box, the block outputs a vector of length N if the Constant value parameter evaluates to an N-element row or column vector. For example, the block outputs a matrix of dimension 1-by-N or N-by-1.

  • When you clear this check box, the block does not output a vector of length N if the Constant value parameter evaluates to an N-element row or column vector.

Programmatic Use

Block Parameter: VectorParams1D
Type: character vector
Values: 'on' | 'off'
Default: 'on'

Block Characteristics

Data Types

double

Direct Feedthrough

no

Multidimensional Signals

yes

Variable-Size Signals

no

Zero-Crossing Detection

no

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced before R2006a