size(array) fails

2 ビュー (過去 30 日間)
Douglas Brenner
Douglas Brenner 2016 年 10 月 27 日
コメント済み: Star Strider 2016 年 10 月 28 日
filteredreducedSection
sz = size(filteredreducedSection)
line one prints 106 columns and 90 rows
Line two gives an error:
Subscript indices must either be real positive integers or logicals.
sz = size(filteredreducedSection)
What gives? Thanks.

採用された回答

Star Strider
Star Strider 2016 年 10 月 27 日
Run this line in your Command Window:
which size -all
If the first result is:
size is a variable.
You’ve found the problem. (This is called ‘overshadowing’ of a funciton.) The solution is to rename your ‘size’ variable.
  3 件のコメント
Douglas Brenner
Douglas Brenner 2016 年 10 月 28 日
Had to close matlab and reopen. Maybe I should have just closed the program. Either way a matlab bug?
Star Strider
Star Strider 2016 年 10 月 28 日
Not a bug at all.
This is the problem:
>> which size -all
size is a variable.
You have to find the ‘size’ variable in your code and rename it. The easiest way is to use the Editor, go to ‘Navigate’ —> ‘Find’ then search on either:
size= -or- size =
depending on your programming style. That should find it. Then rename it to something that makes sense in the context of your code. The Editor should then offer you the opportunity to change all the other uses of your ‘size’ variable. Be careful that you don’t accidentally rename your calls to the size function. (I don’t know if the Editor makes that distinction itself, since I never did it myself and I never tested it.)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by