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

조회 수: 4 (최근 30일)
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

답변 (1개)

Suraj Kumar
Suraj Kumar 2024년 8월 27일
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
鑫鹏
鑫鹏 2024년 8월 27일
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.

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

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by