To workspace block does not read 0 correctly
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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!!
0 comentarios
Respuestas (1)
Orion
el 19 de Nov. de 2014
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 comentarios
Orion
el 19 de Nov. de 2014
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 ?
Ver también
Categorías
Más información sobre Simulink Functions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!