Filter löschen
Filter löschen

Difference between uint8 and logical

13 Ansichten (letzte 30 Tage)
Claire Redfield
Claire Redfield am 16 Jun. 2012
1. Does matlab only make caculations with logical numbers?
2. Sometimes two matrices are in different format, such as one is logical and the other is uint8, shall we transfer the uint8 one into logical one?
3. Even if both matrices are uint8, when making caculations, does matlab still transfer them into logical ones then transfer the result back to uint8 one?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 16 Jun. 2012
MATLAB does not make calculations with logical numbers, except for logical tests. When a logical matrix is used in an arithmetic calculation with a numeric matrix, the logical matrix is treated as numeric.
Please put in a breakpoint in your code at the step before "f = uint8(f)" and examine the range of values in the original "f" matrix. The uint8() type conversion rounds values, so if all entries in the original "f" matrix are less than 1/2 then the result would be all 0's.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by