Automaticlly converting negative values to 0

Hey. This is my code.
Ex_UpperBar * Ey_UpperBar * image(x_LowerBar,y_LowerBar)
Ex_UpperBar * Ey_UpperBar
ans =
-1
image(x_LowerBar,y_LowerBar)
ans =
uint8
89
but it is giving the Answer:
Ex_UpperBar*Ey_UpperBar*image(x_LowerBar,y_LowerBar)
ans =
uint8
0
It is supposed to return -89. How do i fix it? Thanks

 Akzeptierte Antwort

Sulaymon Eshkabilov
Sulaymon Eshkabilov am 18 Mai 2020

0 Stimmen

Use a command int8() or int16() to store your processed data that resolves your task. e.g.: a= -89; b=int8(a)

Weitere Antworten (2)

Sulaymon Eshkabilov
Sulaymon Eshkabilov am 18 Mai 2020
Bearbeitet: Sulaymon Eshkabilov am 18 Mai 2020

0 Stimmen

uint8 cannot store -89 and thus, 0
Thus, store your data in int8 or better int16.
Sulaymon Eshkabilov
Sulaymon Eshkabilov am 18 Mai 2020

0 Stimmen

Store you data in int8 or int16

2 Kommentare

Abad Ch
Abad Ch am 18 Mai 2020
it is in uint8 @Sulaymon Eshkabilov
int16(Ex_UpperBar)*int16(Ey_UpperBar)*int16(image(x_LowerBar,y_LowerBar))

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by