Generate sine wave, using simulation time as time source
Simulink / Sources
The Sine Wave block outputs a sinusoidal waveform. The block can operate in time-based or sample-based mode.
This block is the same as theSine Wave Functionblock that appears in the Math Operations library. If you selectUse external signal
为了Timeparameter in the block dialog box, you get theSine Wave Functionblock.
The block calculates the output waveform.
In time-based mode, the value of theSample timeparameter determines whether the block operates in continuous mode or discrete mode.
0
(默认值)导致块在连续模式下运行。
>0
causes the block to operate in discrete mode.
For more information, seeSpecify Sample Time。
当operating in continuous mode, theSine Waveblock can become inaccurate due to loss of precision as time becomes very large.
ASample timeparameter value greater than zero causes the block to behave as if it were driving aZero-Order Holdblock whose sample time is set to that value.
This way, you can build models with sine wave sources that are purely discrete, rather than models that are hybrid continuous/discrete systems. Hybrid systems are inherently more complex and as a result take more time to simulate.
In discrete mode, this block uses a differential incremental algorithm instead of one based on absolute time. As a result, the block can be useful in models intended to run for an indefinite length of time, such as in vibration or fatigue testing.
The differential incremental algorithm computes the sine based on the value computed at the previous sample time. This method uses the following trigonometric identities:
In matrix form, these identities are:
Because Δtis constant, the following expression is a constant:
Therefore, the problem becomes one of a matrix multiplication of the value of by a constant matrix to obtain 。
Discrete mode reduces but does not eliminate the accumulation of round-off errors, for example,(4*eps)
。这种累积可能发生,因为在每个时间步骤中的块输出计算取决于上一个时间步骤的输出值。
To handle round-off errors when the正弦波块operates in time-based discrete mode, use one of these methods.
Method | Rationale |
---|---|
Insert aSaturationblock directly downstream of the Sine Wave block. |
By setting saturation limits on the Sine Wave block output, you can remove overshoot due to accumulation of round-off errors. |
Set up the Sine Wave block to use the
|
The |
Sample-based mode uses this formula to compute the output of theSine Waveblock.
Ais the amplitude of the sine wave.
p是每个正弦波周期的时间样本的数量。
kis a repeating integer value that ranges from 0 top–1.
ois the offset (phase shift) of the signal.
bis the signal bias.
In this mode, Simulink®setskequal to0
at the first time step and computes the block output, using the formula. At the next time step, Simulink incrementsk和验算的输出块。当kreachesp, Simulink resetskto0
before computing the block output. This process continues until the end of the simulation.
基于样本的计算块在给定时间步骤输出的方法不取决于前一个时间步骤的输出。因此,此模式避免了圆形错误的积累。基于样本的模式支持提供它的子系统中的万博1manbetx重置语义。例如,如果Sine Waveblock is in a resettable subsystem that receives a reset trigger, the repeating integerk
resets and the block output resets to its initial condition.
Data Types |
|
Multidimensional Signals |
|
Variable-Size Signals |
|