How to encounter a 1e-7 decimal place error when using single for calculations in Simulink?
65 次查看(过去 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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1752189/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1752194/image.png)
2 个评论
回答(1 个)
Suraj Kumar
about 19 hours 前
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1760589/image.png)
For more details on “MATLAB Test Manager” please refer to the documentation linked below:
Hope this works for you!
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Outputs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!