How do i keep Matlab from rounding a number so i can put it in a GUI text box

1 回表示 (過去 30 日間)
Ryan
Ryan 2013 年 4 月 24 日
When i do the following:
[column, row] = ginput(1);
newRow = round(row);
newColumn = round(column);
r = YellowFish(newRow, newColumn,1);
g = YellowFish(newRow, newColumn,2);
b = YellowFish(newRow, newColumn,3);
p = ((.02989*r + 0.587*g + 0.114*b)/k)/255;
my p value always ends up a 1 or 0 i am trying to put the actual value in a text box within a GUI but it keeps putting 1 and 0 and not the actual number.

回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 4 月 24 日
p = ((.02989*double(r) + 0.587*double(g) + 0.114*double(b))/k)/255;
  1 件のコメント
Jan
Jan 2013 年 4 月 24 日
Exactly. When YellowFish has an integer type, the result is an integer also:
x = uint8(10)
x * pi
double(x) * pi

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by