JmRag
JmRag

Reputation: 1459

Matlab error in multiplication

this may be an utterly stupid question but I cannot multiply two variables in matlab. I don't know what I am doing wrong.Here's the command window:

>> a(200,200)

ans =

  255

>> a(200,200)*255

ans =

  255

shouldn't the answer of be 65025? obviously I cannot understand what I am doing wrong in this simple example. Thx in advance

Upvotes: 1

Views: 50

Answers (1)

Jens Boldsen
Jens Boldsen

Reputation: 1275

The problem: uint8.

uint8 is a class for holding integers between 0 and 255. Most operations between elements of the class uint8 will give a result in the class uint8, since not all numbers are in the interval of integers between 0 and 255 you do cannot rely on the answer being correct, instead you get the answer closest to being correct. In your case you get 255.

Upvotes: 3

Related Questions