フィルターのクリア

Expected a value representable in the C type 'int'

11 ビュー (過去 30 日間)
榆信
榆信 2023 年 11 月 4 日
回答済み: Walter Roberson 2023 年 11 月 4 日
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);

回答 (1 件)

Walter Roberson
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 .

カテゴリ

Help Center および File ExchangeEvent Functions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by