Why in the Test Assessment I can't use the '==' operator to compare expressions of type real_T within the 'verify' operator?
20 ビュー (過去 30 日間)
古いコメントを表示
When I run a test in which I use a 'verify' operator in a test assessment I obtain the following warning:
"The use of the '==' operator to compare expressions of type real_T within the 'verify' operator may produce unexpected results. Step 'step_0_6605' in Test Sequence 'WiperFunctionSWC_PIL_NominalWorkingConditions/Test Assessment': verify(WiperSpeed==0)"
While when I use an 'assert' operator it works fine.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/980560/image.jpeg)
1 件のコメント
Image Analyst
2022 年 4 月 27 日
What is a "Real_T" data type? Why not just use a normal double variable for WiperSpeed? Does it need to be that Real_T data type?
回答 (1 件)
Gyan Vaibhav
2023 年 10 月 9 日
Hi Domenico,
The warning you encountered is not related to the type of variable you are using, “real_T”, but rather it is related to the precision of floating-point numbers. The following documentation links for both the “verify” and “assert” functions emphasizes the importance of using a threshold when working with floating point numbers:
To address this warning, you can use the following workaround:
thres = 0.001; % Set your desired threshold
verify(abs(WiperSpeed - 0) < thres)
By comparing the absolute difference between “WiperSpeed” and 0 against the threshold in the “verify” statement, you should be able to avoid the warning. I hope this explanation helps.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Test Execution についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!