Borrar filtros
Borrar filtros

How to encounter a 1e-7 decimal place error when using single for calculations in Simulink?

65 visualizaciones (últimos 30 días)
I created a model in Simulink for testing the Simulink test tool. The division module was used in the model, and I found that the Divide module introduced calculation accuracy, which caused to fail the Simulink test. How can discard data with 1e-7 or other specified precision?
I already know that in Simulink test cases, error precision can be set to ignore calculation errors of specified precision. But if multiplication continues after the division module, the calculation error will accumulate and exceed the set error accuracy.
Looking forward to everyone's reply

Respuestas (1)

Suraj Kumar
Suraj Kumar hace alrededor de 21 horas
Based on my understanding, you are facing a precision issue due to a quantization error. To effectively manage this precision issue, you can apply a relative tolerance to your test case. This approach allows for small, acceptable deviations relative to the magnitude of the expected value, accommodating the quantization error.
To set the relative tolerance, you can navigate to ‘Baseline Criteria’ section in the test case editor where tolerance for signals are specified. Identify the signals for precision loss and set its ‘Relative Tolerance’ to 1% which allows the test to pass if the deviation is within 1% of the expected value.
You can refer to the output for better understanding:
For more details on “MATLAB Test Manager” please refer to the documentation linked below:
Hope this works for you!
  1 comentario
鑫鹏
鑫鹏 hace alrededor de 21 horas
Thank you for your reply. I have attempted to set these error values in the Excel file of the test case. However, when using this division module (uploaded test model) as a pre order sub calculation unit, if multiplication is used later, the error generated by this division module will accumulate and exceed the pre-set allowable error.
In fact, the model uploaded is a small computational part of my unit testing.

Iniciar sesión para comentar.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by