Main Content

Variable Pulse Generator

Generate ideal, time varying pulse signal

Since R2020b

  • Variable Pulse Generator block icon

Simulink / Discontinuities


Use the Variable Pulse Generator block to create ideal modulated pulse signals.

Generally speaking, the output pulse of the block is described by


where pw is the output pulse width.

For an implementation of Pulse Width Modulation, see PWM.


expand all

This example shows you how to model an ideal voltage controlled oscillator using the Variable Pulse Generator block to create the frequency oscillations.

A voltage controlled oscillator uses an input tuning voltage to produce waveforms of varying frequency. Over a small range of voltages, the relationship between the input voltage ($V_{in}$)and the output oscillation frequency ($F$) is proportional and can be expressed as

$$F(t) = K_c . V_{in}(t) + F_0 (1)$$


  • $K_c$ is the oscillator sensitivity in Hz/V

  • $f_0$ is the quiescent frequency, or nominal frequency of the oscillator at $V_{in} = 0$

In the included vco_using_vpg model, the desired oscillation frequency signal F_{in}(t) is generated using the formula shown in equation (1). In this model, the tuning voltage $V_{in}$ is a sinusoidal waveform.



expand all

Desired duty cycle of the pulse P, specified as scalar within the range [0,1].

Data Types: double

Time between rising edges of consecutive pulses of the output signal. A smaller value represents a higher frequency pulse.

Data Types: double


expand all

Modulated output pulse signal corresponding to input duty cycle.

Data Types: double


expand all

Enable this parameter to allow the output pulse signal to support pulses of width 0.


Enabling this parameter causes the block to have direct feedthrough. This can cause algebraic loops in your model.

Select whether the block should operate in continuous or discrete sampling modes.

By default, the block uses continuous sampling mode as it improves simulation performance with variable step solvers.

Select discrete sampling mode if you need to:

  • use a fixed-step solver

  • generate code

  • sample the block output

Specify the rate at which the block samples input duty cycle signal. This sampling rate becomes the resolution of the output pulse signal.


This parameter requires that Sampling mode is set to discrete

Block Characteristics

Data Types


Direct Feedthrough


Multidimensional Signals


Variable-Size Signals


Zero-Crossing Detection



expand all

Extended Capabilities

Version History

Introduced in R2020b

See Also