Expected a value representable in the C type 'int'
조회 수: 11 (최근 30일)
이전 댓글 표시
I'm using MATLAB function blocks in Simulink. but there were some errors about data type. I can't understand the error messages. what made this error?
function xd = fcn(xdd,t)
t = t*10+1;
xd = xdd(t,1);
function xd = fcn(xdd,t)
t = t*10+1;
xd = xdd(t,1);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1529197/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1529202/image.png)
댓글 수: 0
답변 (1개)
Walter Roberson
2023년 11월 4일
You are taking whatever arrives in t and multiplying it by 10 and adding 1, and then you try to use that as an index into the zdd variable.
But the values into t are derived from the system clock -- and the system clock is not running at exact integer multiples of 1/10th second: it is running at about 0.025 seconds or so.
If you configured continuous time then remember that clock time may vary arbitrarily, being changed adapatively to meet integration tolerances.
If you configured discrete time then you needed to configure a larger step time -- and if you do use 1/10th of a second or integer multiples of that, then you should probably toss in a round(t) because the timer is not certain to run exactly at 1/10 because double precision cannot exactly represent 1/10 .
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Event Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!