フィルターのクリア

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

1 回表示 (過去 30 日間)
Benjamin
Benjamin 2012 年 6 月 25 日
Hi, so I think i know what the issue is, that being the " /2 " portion of the code giving a decimal as an answer, but I thought the addition of " .5 " would fix that as it gives me all my correct values. My question is, does this warning actually affect the out come of my calculations?
pixel_seg.A81 = middle.middle_interpolate((28536/2+.5):(28598/2),:); %gives warning
pixel_seg.B81 = middle.middle_interpolate((28599/2+.5):(28634/2),:); %gives warning
tap.tapA81B81 = (((abs((sum(pixel_seg.A81)/length(pixel_seg.A81))-...
(sum(pixel_seg.B81)/length(pixel_seg.B81))))/...
(sum(pixel_seg.B81)/length(pixel_seg.B81)))*100);
Thanks for your time

採用された回答

Walter Roberson
Walter Roberson 2012 年 6 月 25 日
28536 is already even, so do not add 0.5 after dividing by 2.
28599 is odd, so it would need to be rounded after dividing by 2.
Using floor() or ceil() is safer than adding 0.5, due to potential round-off error.
  3 件のコメント
Andrei Bobrov
Andrei Bobrov 2012 年 6 月 25 日
please use 'ceil'
Benjamin
Benjamin 2012 年 6 月 25 日
Thanks so much guys

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by