how to avoid rounding off error in simulink calculations?
조회 수: 6 (최근 30일)
이전 댓글 표시
Hi, I have a simulink model including a level 2 S function block. The code in the s function ia a numerical scheme that solves a PDE . When this code is run as a script alone the results are exactly accurate..but when the model is simulated they results differ from the accurate ones. I have checked and compared the results thoroughly and I guess in the very first step there is a rounding off error which is causing the results to differ. With each iteration the error is getting summed up. Is there any way to avoid this error?? Please help. I am using all variables in double data type. Please answer. Thanks.
댓글 수: 2
dpb
2014년 6월 22일
Insufficient data...
What is the input that varies for starters and how much is it off the expected value?
채택된 답변
Kaustubha Govind
2014년 6월 23일
The difference between 46.7889e5 and 46.7890e5 is 10, which is too large to be a rounding error. Most likely, what is happening is that the From Workspace block is interpolating your data because the time-steps corresponding to your data points don't match with the simulation solver time-steps exactly. You may want to either adjust the time values in your workspace data, or uncheck the "Interpolate Data" option on the From Workspace block dialog.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Array and Matrix Mathematics에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!