登录论坛

查看完整版本 : [求助]我也求助个小疑难


tolabfans
2008-08-01, 18:36
b=t(2)+t(4);
c=t(1)+t(3);

运行上面二句简单的代码,可以执行,可总是警告,不知为啥。

Warning: Integer operands are required for colon operator when used as index.

意思是:需要整数操作符当冒句用作index时,不知啥意思

tolabfans
2008-08-01, 19:42
Section 41: Integer Operands Are Required for Colon Operator When Used as Index
Warning: Integer operands are required for colon operator
when used as index.

Explanation:
You have used a noninteger value as one of the parameters (starting value, increment, or stopping value) for the colon ( :) operator when using it to create a vector of indices to reference into a function.

Common causes:
You performed computations to obtain the starting or stopping values for the indexing but the result of those computations was not exactly an integer.

Solution:
Modify the index computations using the FIX , FLOOR , CEIL , or ROUND functions to ensure that the indices are integers. You can test if a variable contains an integer by comparing the variable to the output of the ROUND function operating on that variable when MATLAB is in debug mode on the line containing the variable.

在网上找到一段英文说明,解决了。加个round即可