The calculation result of the Matlab function is incorrect.
2 ビュー (過去 30 日間)
古いコメントを表示
When I was conducting Simulink simulation, I encountered the following issues:
At the same time, the reference value is fixed and different id_p are entered has different calculation results Te_ P. The error is equal to the square of (Te_p-Reference).The key issue is that the calculated value in scenario 2 is closer to the reference value, but the calculated error result is larger, which is contradictory. Please refer to the picture.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1571317/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1571322/image.jpeg)
2 件のコメント
madhan ravi
2023 年 12 月 18 日
編集済み: madhan ravi
2023 年 12 月 18 日
Can you perhaps try it with fixed point data instead? Uint64 with minute slope, 1e-8 for example?
採用された回答
Ganesh
2023 年 12 月 19 日
From the values, I can see that the error value is being computed wrongly for every value of "Te_up". However, the value of "Te_ref_up" being used for error calculation is consistent, with the value being 0.6113857267404.
Here are the possible resolutions for the issue you are facing:
- Clear all the variables in Model Workspace and start fresh.
- Use a higher precision data structure for storing the reference value.
- Ensure that "Te_ref_Up" is not changing during the simulation.
- Check the value of the signal that is being connected to the function block to know what value is being passed.
Please refer to the following documentation on defining variables inside a MATLAB Function Block :
Hope that helps!
If the issue persists, kindly reach out to MathWorks Technical Support
Thanks,
Ganesh S
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Simulink Functions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!