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

4 views (last 30 days)
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

Answers (1)

Suraj Kumar
Suraj Kumar on 27 Aug 2024
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 Comment
鑫鹏
鑫鹏 on 27 Aug 2024
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.

Sign in to comment.

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!