Clear Filters
Clear Filters

The calculation result of the Matlab function is incorrect.

1 view (last 30 days)
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.
  2 Comments
madhan ravi
madhan ravi on 18 Dec 2023
Edited: madhan ravi on 18 Dec 2023
Can you perhaps try it with fixed point data instead? Uint64 with minute slope, 1e-8 for example?
hard study
hard study on 19 Dec 2023
Thank you for your reply. This is just my mistake, due to the issue of data latency.

Sign in to comment.

Accepted Answer

Ganesh
Ganesh on 19 Dec 2023
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:
  1. Clear all the variables in Model Workspace and start fresh.
  2. Use a higher precision data structure for storing the reference value.
  3. Ensure that "Te_ref_Up" is not changing during the simulation.
  4. 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
  1 Comment
hard study
hard study on 19 Dec 2023
Moved: Stephen23 on 19 Dec 2023
Thank you for your reply. This is just my mistake, due to the issue of data latency.

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!