integer operands are required for colon operator when used as index
9 ビュー (過去 30 日間)
古いコメントを表示
Why do I get the warning "integer operands are required for colon operator when used as index" in the final line is this code:
vector_examined = rand(items,1); criteria = vector_examined < value; passes = find(criteria);
2 件のコメント
the cyclist
2012 年 1 月 24 日
Would it be possible for you to post some self-contained code that will produce the error (without us having to guess what "items" and "value" look like)? For example, if I choose items=5 and value=0.2, your code runs just fine for me.
Walter Roberson
2012 年 1 月 24 日
I do not see anything obvious. Is it possible that you typed this line in for us, rather than using copy-and-paste? Could you also show us the previous line?
回答 (1 件)
nick
2025 年 4 月 16 日
Hello Ulrik,
Kindly share the entire code and associated files to help debug the issue.
The warning "integer operands are required for colon operator when used as index" typically occurs when one attempts to use non-integer values in indexing operations. Please ensure that:
- 'items' is a positive integer, as it defines the size of the vector
- 'value' is a scalar or a compatible size for comparison with 'vector_examined'.
Kindly refer to the following documentation to know more about indexing in MATLAB:
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!