필터 지우기
필터 지우기

To workspace block does not read 0 correctly

조회 수: 2 (최근 30일)
Matthias
Matthias 2014년 11월 19일
댓글: Orion 2014년 11월 19일
Dear Community!
I am reading double values consisting of 0s and 1s via the "to workspace" into the workspace (the 0s are checked to equality to 0). However some of the 0 values are not loaded as 0 into the workspace but as values in the range in between 2^-15 to 2^-16 (above the resolution of double...?). Also changing the sample time changes the positions of the wrong entries.
If you need more information don't hesitate to inform me.
Thank you very much!!

답변 (1개)

Orion
Orion 2014년 11월 19일
This is a classic problem of numerical precision.
several ways to treat it :
- before sending your data in the workspace, convert it in logical or integer.
- in post-treating, convert your data , such as : simout = bool(simout)
- instead of comaring to 0, compare to a reference value (0 in your case) and epsilon
, in this last way, you consider that a tiny difference (10^-16) is OK.
instead of
simout==0
search for
abs(simout-0) < 10^-14
  댓글 수: 2
Matthias
Matthias 2014년 11월 19일
Thank you for your suggestions!
Unfortunately none of these are applicable in my case because the underlying model is quite fixed. I wonder if there is some setting to prevent this precision problem because the input data is binary really 0 but the workspace data has some binary value unequal to 0. Double values are unfortunately obligatory in our environment.
BTW, background is that these values as you can assume used as booleans for logical blocks. Of course we could mask them and add some functionality to handle these problems, but this would really be the last solution. We are working with this environment for years and until now never faced this problem...?
Orion
Orion 2014년 11월 19일
If you're data is supposed to be used in logical condition, it shouldn't be calculated as a double in the model at all ? It seems to me there is a modeling error (even if this kind of modeling is current, it's not recommended).
Also, Did you change of Matlab Version ?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by