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!