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即可