Boolean to double without changing the boolean

10 ビュー (過去 30 日間)
Erik Johan
Erik Johan 2014 年 10 月 26 日
編集済み: Rajanya 2025 年 5 月 14 日
Im trying to make a switching signal for a DCAC inverter.
When i convert my boolean signal from the "Relational Operator" to a double signal (to run the switches), the signal changes from the correct digital switching signal into an partial digital and partial triangular signal.
So the "data type converter" do not give me the digital 1 and 0 that i want.
Which settings are necessary to get a clean 1 and 0 double signal?

回答 (1 件)

Rajanya
Rajanya 2025 年 5 月 14 日
編集済み: Rajanya 2025 年 5 月 14 日
I had faced a similar problem when working with continuous-time blocks in a model that used fixed step solvers. The problem arises because the data points are obtained and plotted based on the fundamental sample time of the model and 'Scope' joins all these points with straight lines, creating the illusion of sloped or analog transitions, even though the actual signal switches are instantaneous. This effect becomes more and more prominent with increasing fundamental sample time of the model.
With very low sample times, this effect is diminished. Also, if the 'continuous' blocks are made to operate in discrete mode (sample time > 0 and an integer multiple of the fundamental sample time), the effect is removed.
Here is a demonstration -
For this sample model, if I set the sample time of both the sine wave and the triangle generator to be equal to 0.1, which is also set as the fundamental sample time of the solver (selected fixed step 'auto'). The effect does not come up (see graph below)-
When I set the sample time of both the sine wave block and the triangle generator to be 0 (continuous), keeping the fundamental sample time 0.1, I get the effect (see graph below) -
N.B.: The slope comes out when output data type is non-boolean. The slope of the lines increases with increasing fundamental sample time.
However, the data points remain the same signifying it's just Scope's representation that is causing the difference, as shown below -
N.B.: The gap between the data points is 0.1s. Scope connects all the points and connecting the transition points create a sloped line.
When I now reduce the fundamental sample time to 0.0001, the effect is much diminished, as expected (since the gap between two sampled data points reduce to the same) -
Therefore, the issue is purely representational and has nothing to do with correctness. It can be minimized (to negligible) under the given conditions, by reducing the fundamental sample time of the model, or can be completely avoided by using variable-time solvers or operating all continuous time blocks in proper discrete mode with fixed step solvers.
Thanks!

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by