Data Type Conversion does not convert to boolean when attached to transfer function block

8 ビュー (過去 30 日間)
Hello,
I attached a "Data Type Conversion" block to a PT1 low pass filter (transfer function) trying to convert the ouptut signal from double to boolean. Unfortunately this did not work as expected - the output was constantly '1' or '0'.
The same issue appears when a logic block is used after the transfer function. (I assume the same type of conversion is made internally.)
I have to convert the double value to an integer first, and than to boolean. This does the trick but in principle it should not matter in which block a double value is created. Converting e.g. a pulse source double output directly to boolean works certainly.
This strange behavior has been encountered in 2018a and 2019a and with all possible conversion settings.
Any suggestions?
Thank you,
Timo
Here comes some additional information:
Block diagram
Simulation result at Conv1_out: directly converted to boolean
The direct conversion delivers a constant signal, only.
Simulation result at Conv2_out with first conversion block set to 'int8':
Now, the output looks as expected.

採用された回答

Fangjun Jiang
Fangjun Jiang 2020 年 6 月 9 日
Your filter coefficient 50e-6 makes it respond faster but the output will "creep" for a long time.
The boolean conversion or the boolean(a) or logical(a) function basically is to check if value a is equal to zero. For double precision data, "true zero" is hard to get. see "help realmin".
You "Filter_out" value never reaches "zero" for double precision data. Log the data to workspce and check a value that seems to be 0 but the real value is around 2e-22 (depending on your solver and time step).
The rest makes sence if you add a "convert to integer" in the middle. To do it directly, use a Comparator block and see "help eps".
  1 件のコメント
Timo Dietz
Timo Dietz 2020 年 6 月 10 日
This is embarrassing. I was totally misled by the cursor readings of '0.0'.
You are certainly right - many thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by