Potential Signal Editor Bug

14 ビュー (過去 30 日間)
Kevin Ferguson
Kevin Ferguson 2025 年 2 月 18 日
回答済み: Carl Isted 2025 年 2 月 20 日
Using signal editor, I have created an input of Time = 0:0.001:200 and a Sine Wave output using Output = sin(2*pi*[0:0.001:200]). However, when I do not get a pure sine wave output, which is causing our project issues.
I have reproduced the error with a Minimal Working Example (MWE) which is attached.
Could somebody in Mathworks please investigate. I am particularly interested in a pragmatic solution to work round this bug.

採用された回答

Carl Isted
Carl Isted 2025 年 2 月 20 日
This issue is caused by small differences in the spacing of the time steps in the "timeseries" data of the signal due to finite precision of floats. You can resolve this by using "timetables" instead of a "timeseries" to create a uniform time step for the data in the "Signal Editor" block. For example, the following code will generate a sine wave with a sample rate of 0.001 seconds:
timestep=seconds(0.001);
inputvector=sin(2*pi*(0:0.001:200))';
TT = timetable(inputvector,'TimeStep',timestep);
Regards,
Carl

その他の回答 (1 件)

Samar
Samar 2025 年 2 月 20 日
Upon attaching a scope to the Signal Editor block, it seems that the signal editor block is working just fine.
Simulink’s Sine Wave block might not be producing a perfect sine wave when the Simulink Model Solver is “discrete” rather than a “continuous" one. This is because the sine wave frequency is not an integral multiple of the selected sample-frequency. This causes accumulation of round-off errors.
The reason and the solution to accumulation of round-off errors is explained below in the MathWorks provided documentation for “Sine Wave” block:
Refer the given link to know more about the solver settings:

カテゴリ

Help Center および File ExchangeSources についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by